ConvincingMail - Email Marketing SoftwareConvincingMail
 
Email Marketing Software

Welcome Guest Search | Active Topics | Members | Log In | Register

Using two Autocomplete controls with shared id field Options · View
Andre
Posted: Saturday, November 14, 2009 3:30:26 AM
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
trooper
Posted: Saturday, November 14, 2009 4:00:31 AM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 80
Points: 152
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
Andre
Posted: Sunday, November 15, 2009 3:46:43 AM
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.
trooper
Posted: Sunday, November 15, 2009 8:14:36 AM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 80
Points: 152
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
Andre
Posted: Monday, November 16, 2009 5:58:04 AM
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
trooper
Posted: Monday, November 16, 2009 6:11:23 AM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 80
Points: 152
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
Andre
Posted: Tuesday, November 24, 2009 6:56:16 AM
Rank: Newbie
Groups: Member

Joined: 7/29/2009
Posts: 6
Points: 18
Location: Germany
Anything works fine now.
Thanks for you support!
trooper
Posted: Tuesday, November 24, 2009 7:01:47 AM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 80
Points: 152
Thank you for using ConvincingMail tools and servicies ;)

Thanks
Mikhail
afbueno
Posted: Sunday, January 17, 2010 4:45:04 AM
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
trooper
Posted: Sunday, January 17, 2010 5:49:19 PM
Rank: Administration
Groups: Administration

Joined: 11/18/2007
Posts: 80
Points: 152
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
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.104 seconds.