I have been struggling with putting the combo into a grid and doing a client side autocomplete for a day now. I dont see any samples on this which makes me wonder if no one is doing this.
Here is what I am trying to do: I have grid that is bound to a datatable server side, in the datatable there are two related columns ClassID, Class. These are are really one data value for a lookup. I have a template column defined as follows.
Here is the javascript for lookups:
The lookup service works just fine, if you type in the box it pulls back matching rows and displays them in the combo and I can select the item.
The two things I cannot figure out.
1. How to populate the combo with the initial value, I could do this server side when the edit postback comes in.
2. This is the big one as I cannot figure out a workaround. How do I get the value of the selected item back into the form field on the client? In my code, I put the statement alert(val); in the selection and that has the correct value in it when an item is selected; I just cant figure out how to get it into the form field.
None of the samples show a client side autocomplete combo populated by a service inside of a grid.
Here is what I am trying to do: I have grid that is bound to a datatable server side, in the datatable there are two related columns ClassID, Class. These are are really one data value for a lookup. I have a template column defined as follows.
| <telerik:GridTemplateColumn HeaderText="Class" UniqueName="Class" SortExpression="Class" ShowSortIcon="true" HeaderStyle-Width="200"> |
| <ItemTemplate> |
| <asp:Label ID="Label1" runat="server" Text='<%# Eval("Class") %>' /> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <telerik:RadComboBox ID="ClassCombo" runat="server" Width="190px" Height="200px" MarkFirstMatch="true" |
| OnClientItemsRequested="OnClientItemsRequested" OnClientItemsRequesting="OnClientItemsRequesting" OnClientDropDownClosed="OnClientDropDownClosed" |
| OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" |
| EnableLoadOnDemand="true" AllowCustomText="false" > |
| <ExpandAnimation Type="none" /> |
| <CollapseAnimation Type="none" /> |
| <WebServiceSettings Path="/Lookup.asmx" Method="Classes" /> |
| </telerik:RadComboBox> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
Here is the javascript for lookups:
| function OnClientItemsRequesting(sender, args){ |
| startTime = new Date(); |
| } |
| function OnClientItemsRequested(sender, args){ |
| var endTime = new Date(); |
| } |
| function OnClientSelectedIndexChanged(sender, args) { |
| var item = args.get_item(); |
| var text = item.get_text(); |
| var val = item.get_value(); |
| alert(val); |
| } |
| function OnClientDropDownClosed(sender, args) { |
| sender.clearItems(); |
| if(args.get_domEvent().stopPropagation) |
| args.get_domEvent().stopPropagation(); |
| } |
The lookup service works just fine, if you type in the box it pulls back matching rows and displays them in the combo and I can select the item.
The two things I cannot figure out.
1. How to populate the combo with the initial value, I could do this server side when the edit postback comes in.
2. This is the big one as I cannot figure out a workaround. How do I get the value of the selected item back into the form field on the client? In my code, I put the statement alert(val); in the selection and that has the correct value in it when an item is selected; I just cant figure out how to get it into the form field.
None of the samples show a client side autocomplete combo populated by a service inside of a grid.