This is a migrated thread and some comments may be shown as answers.

DropDownItemTemplate is not working

0 Answers 83 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Alper
Top achievements
Rank 1
Alper asked on 13 Apr 2018, 02:26 PM

Hi;

I'm trying your component. I had added an autocompletebox to a page and created itemtemplate as described in demo. But only client template is working and i can't add attributes to client template. For that reason i need to use serverside template. When i use DropDownItemTemplate , i'm not getting any error but it's showing DataTextField, not template... Here is my code for webservice and aspx;

ClientSide Event for webservice filter

  function requestingIdNr(sender, eventArgs) {
        var context = eventArgs.get_context();
        //Data passed to the service.
        context["ogrnr"] = "det_info";
    }

              <telerik:RadAutoCompleteBox ID="txtNr" runat="server" Width="300px" AllowCustomEntry="true"
                    Filter="StartsWith" DropDownWidth="300px" DropDownHeight="250px" DataTextField="idnr"
                    InputType="Token" MaxResultCount="10" MinFilterLength="3" TextSettings-SelectionMode="Single"
                    AutoPostBack="true" OnClientRequesting="requestingIdNr" OnEntryAdded="txtNr_EntryAdded" OnEntryRemoved="txtNr_EntryRemoved">
                    <WebServiceSettings Method="fillActBoxTC" Path="AutoCompletes.asmx" />
                    <DropDownItemTemplate>
                        <table >
                            <tr>
                                <td style="width: 25%"><%# DataBinder.Eval(Container.DataItem, "idnr")%>
                                </td>
                                <td style="width: 50%">
                                    
                                </td>
                            </tr>
                            <tr>
                                <td>Name:
                                </td>
                                <td>
                                    <%# DataBinder.Eval(Container.DataItem, "name")%>
                                </td>
                            </tr>
                            <tr>
                                <td>Class:
                                </td>
                                <td>
                                    <%# DataBinder.Eval(Container.DataItem, "classcode")%>
                                </td>
                            </tr>
                            <tr>
                                <td>Nr:
                                </td>
                                <td>
                                    <%# DataBinder.Eval(Container.DataItem, "nr")%>
                                </td>
                            </tr>
                        </table>
                    </DropDownItemTemplate>
                </telerik:RadAutoCompleteBox>

And WebService Side :

        [WebMethod(EnableSession = true)]
        public AutoCompleteBoxData fillActBoxTC(RadAutoCompleteContext context)
        {
            string searchString = context.Text;
            idsBE.idsDataTable data = bll.getidsbyNr(((compBE.usrRow)Session["actUser"]).compid, searchString);
            List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();

            foreach (idsBE.idsRow row in data)
            {
                AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
                childNode.Text = row["idnr"].ToString();
                childNode.Value = row["idnr"].ToString();
                childNode.Attributes.Add("idnr", row["idnr"].ToString());
                childNode.Attributes.Add("name", row["name"].ToString());
                childNode.Attributes.Add("classcode", row["classcode"].ToString());
                childNode.Attributes.Add("nr", row["nr"].ToString());
                result.Add(childNode);
            }

            AutoCompleteBoxData res = new AutoCompleteBoxData();
            res.Items = result.ToArray();

            return res;
        }

No answers yet. Maybe you can help?

Tags
AutoCompleteBox
Asked by
Alper
Top achievements
Rank 1
Share this question
or