|
|
Rank: Newbie Groups: Member
Joined: 7/29/2009 Posts: 6 Points: 18 Location: Germany
|
Hi,
I need a solution for something like this: I've a Autocomplete control for suggesting the article number. As people often not know an article number they can also searching the description with a second Autocomplete control. Both, the article number and the description are bind to a text control with the id of the article.
Now I'm looking for a way to programmatially set the the article description when the number is entered and vice versa.
Maybe somebody has an idea how to do this.
My idea would be to wait until Autocomplete set the id, calling a javascript for an AJAX function to get the missig article number or description - what ever is needed. What client event can I use in this case?
Thanks,
Andre
|
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 73 Points: 131
|
Hi Andre, Not very clear from your description what you want to do. Do you have 2 fields one for ID and the other for Description?
Or you have one field for both ID and description?
Thanks Mikhail
|
|
Rank: Newbie Groups: Member
Joined: 7/29/2009 Posts: 6 Points: 18 Location: Germany
|
Ok, here is the code to explain a little bit more Code: <td> <asp:TextBox ID="ArtID" runat="server" Visible="false" Enabled="false" Width="10"></asp:TextBox> <asp:TextBox ID="Artikelnummer" runat="server"></asp:TextBox> <cc4:AdvancedAutoSuggestExtender HeaderTemplate="<div style='background-color:#BDC7D8; height:20px; text-align:center;'>#{Contents}</div>" SuggestOnEmptyField="false" TargetControlID="Artikelnummer" ServiceUrl="~/Suggestions.asmx/ArtNrSuggest" LoadingText="Suche ..." LoadingDivCss="loading" UpdateField="ArtID" ID="ArtNrEX" runat="server" /> </td> <td colspan="4"> <asp:TextBox ID="Artikelbezeichnung" runat="server" CssClass="resize"></asp:TextBox> <cc4:AdvancedAutoSuggestExtender HeaderTemplate="<div style='background-color:#BDC7D8; height:20px; text-align:center;'>#{Contents}</div>" SuggestOnEmptyField="false" TargetControlID="Artikelbezeichnung" ServiceUrl="~/Suggestions.asmx/ArtNameSuggest" LoadingText="Suche ..." LoadingDivCss="loading" UpdateField="ArtID" ID="ArtNameEx" runat="server" /> </td>
So the ArtID is ever updatet what way ever is choosed to find the article. But when you choose it with the article number I like to also change the description of the artikel.
|
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 73 Points: 131
|
Hi, you can use OnClientItemSelected event. create a JS function to populate the description. it should look like this: function updateDescription(sender, item){ $('put_the_clientside_description_box_ID_here').value=item.TitleValue; }
your control will look like this: <cc4:AdvancedAutoSuggestExtender HeaderTemplate="<div style='background-color:#BDC7D8; height:20px; text-align:center;'>#{Contents}</div>" SuggestOnEmptyField="false" TargetControlID="Artikelnummer" ServiceUrl="~/Suggestions.asmx/ArtNrSuggest" LoadingText="Suche ..." OnClientItemSelected = "updateDescription" LoadingDivCss="loading" UpdateField="ArtID" ID="ArtNrEX" runat="server" />
Hope this helps Thanks Mikhail
|
|
Rank: Newbie Groups: Member
Joined: 7/29/2009 Posts: 6 Points: 18 Location: Germany
|
Hi Mikhail, this works fine to copy the article number also in the textbox for the description. But I need to copy an other value to it, one textbox should holt the article number and the other one the article description. Do you have also a solution for? I post my code behind to explain the maining of: Code: [WebMethod] [ScriptMethod] public string ArtNrSuggest(string tryValue, string[] additionalParams) { List<SuggestionItem> items = new List<SuggestionItem>(); string FindWhat = tryValue;
OleDbConnection con = new OleDbConnection(GetConnectionString()); con.Open();
OleDbCommand cmd = new OleDbCommand(String.Format("SELECT TOP 20 ID, Artikelnummer FROM Artikel WHERE Artikelnummer LIKE '%{0}%'",FindWhat), con);
OleDbDataReader Sdr = cmd.ExecuteReader(); while (Sdr.Read()) { //parce data from DataReader string art = string.Empty; string id = string.Empty; if (Sdr["Artikelnummer"] != null && Sdr["Artikelnummer"] != DBNull.Value) { art = Sdr["Artikelnummer"].ToString(); } if (Sdr["ID"] != null && Sdr["ID"] != DBNull.Value) { id = Sdr["ID"].ToString(); } //create SuggestionItem SuggestionItem suggestionItem = new SuggestionItem(); suggestionItem.Title = art; suggestionItem.Id = id; //add item to the list items.Add(suggestionItem); } con.Close(); //create result Item SuggestionResult suggestionResult = new SuggestionResult(); suggestionResult.Items = items.ToArray(); suggestionResult.Header = new BasicSuggestionTemplate("Vorschläge zu Ihrer Suche:"); // suggestionResult.Footer = new BasicSuggestionTemplate("Powered by ConvincingMail"); return suggestionResult.ToJSON(tryValue); }
[WebMethod] [ScriptMethod] public string ArtNameSuggest(string tryValue, string[] additionalParams) { List<SuggestionItem> items = new List<SuggestionItem>();
string FindWhat = tryValue;
OleDbConnection con = new OleDbConnection(GetConnectionString()); con.Open();
OleDbCommand cmd = new OleDbCommand(String.Format("SELECT TOP 20 ID, Bezeichnung FROM Artikel WHERE Bezeichnung LIKE '{0}%'", FindWhat), con);
OleDbDataReader Sdr = cmd.ExecuteReader(); while (Sdr.Read()) { //parce data from DataReader string art = string.Empty; string id = string.Empty; if (Sdr["Bezeichnung"] != null && Sdr["Bezeichnung"] != DBNull.Value) { art = Sdr["Bezeichnung"].ToString(); } if (Sdr["ID"] != null && Sdr["ID"] != DBNull.Value) { id = Sdr["ID"].ToString(); } //create SuggestionItem SuggestionItem suggestionItem = new SuggestionItem(); suggestionItem.Title = art; suggestionItem.Id = id; //add item to the list items.Add(suggestionItem); } con.Close(); //create result Item SuggestionResult suggestionResult = new SuggestionResult(); suggestionResult.Items = items.ToArray(); suggestionResult.Header = new BasicSuggestionTemplate("Vorschläge zu Ihrer Suche:"); // suggestionResult.Footer = new BasicSuggestionTemplate("Powered by ConvincingMail"); return suggestionResult.ToJSON(tryValue); }
So ArtNrSuggest needs a query like: new OleDbCommand(String.Format("SELECT TOP 20 ID, Artikelnummer, Bezeichnung FROM Artikel WHERE Artikelnummer LIKE '%{0}%'",FindWhat), con); Where the third field 'Bezeichnung' will be the description I like to use for the seccond textbox when the articel number will be changed. Thanks, Andre
|
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 73 Points: 131
|
you need to inherit the SuggestionItem class and add an extra property for description.
You can view an example in the demo project. There is an AdvancedSuggestionItem which adds an "ImageUrl" property into JSON. That is just an example and you can make it more advanced
Hope this makes sense Thanks Mikhail
|
|
Rank: Newbie Groups: Member
Joined: 7/29/2009 Posts: 6 Points: 18 Location: Germany
|
Anything works fine now. Thanks for you support!
|
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 73 Points: 131
|
Thank you for using ConvincingMail tools and servicies ;)
Thanks Mikhail
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2010 Posts: 1 Points: 3 Location: Brasil
|
Good morning!
I'm using the control and I have a big problem, I do not use WAS. "Asmx" I'm using WCF and I can not do work, could someone help?? Congratulations control was very good, just missing granted database with WCF! Thank you! Anderson
|
|
Rank: Administration Groups: Administration
Joined: 11/18/2007 Posts: 73 Points: 131
|
Hi afbueno, I think you just need to create a correct JSON serverside. You can load data from DB or any other source.
please check the demo project included with the source code of the control.
Thanks Mikhail
|
|
|
Guest |