I have my webcombo configured to ComboTypeAhead = Suggest and EnaleXmlHttp = true
Inside the InitializeDataSource event handler I use the WebCombo.DisplayValue property to create the new DataSet, using a select similar to "SELECT top 10 WHERE [ColumnName1] like [WebCombo.DisplayValue]% AND [ColumnName2] = [ContextualDataValue]"
The problem is that the value of ContextualDataValue should come from the client too. Since this is an AJAX call I have no access to any information or object besides the WebCombo being passed in the event handler.
Is there a way to send more information to the server on the AJAX call that triggers the InitializeDataSource event?
Maybe there's a way to hide or append that contextual information to the WebCombo on the client side before the AJAX call takes place?
I think this is a very common scenario. Maybe the WebCombo should have a client side property "Context" and the equivalent server side property so there's more information available to the programmer when the InitializeDataSource event fires.
Great, that's much much easier. I was tempted to try this too yesterday, but figured the whole form would not be available in the callback, so I thought hidden input values would be lost, which luckily is not the case.
Thanks for sharing the knowledge in forums.
Thanks for the answer Rumen.
Playing with the code yesterday I found an easier way. I added a normal ASP NET HiddenField control to my page. On the client side I set the hidden field to that additional information I will need during the AJAX call:
{
hiddenField.value = 'test';
When the user types a value in the WebCombo the InitializeDataSource event triggers. If I check the value of HiddenField1, it is equal to "test", which is what I set it to on the client side.
I'm not sure what's going on underneath. I guess the WebCombo is posting the form to the server, so all the input elements have their values set correctly by the time the InitializeDataSource triggers.
Hello Oscar,
Thanks for writing. This does not appear easy, and while I will investigate this in detail and hopefully write later, I have something that can get you started. I am looking at our Samples application, and the AJAX -> WebCombo Advanced Ajax example in particular and here is what I see in the source:
http://samples.infragistics.com/2008.2/webfeaturebrowser/srcview.aspx?path=WebGrid/AjaxImplementation/TypeAheadCombo.src&file=TypeAheadCombo.aspx&font=3
if(search!="" &&search.length==5){ timestamp=new Date().getTime(); oWebCombo1.getGrid().Bands[0].Columns[0].setFooterText("Loading ..."); xmlReq.open("GET","TypeAheadCombo.aspx?rows=true&searchString="+search,true); //Send request.
xmlReq.send(null);
I am still trying to put the pieces together since there is a lot of custom code, but I guess if you are able to get to this way, you will be able to append one addtional string to the GET request, that will later be available on the server in the Page.Request collection of server variables.
Hope this helps.