Hi,I have a webcombo which binds to a datatable using the datasouceid property.This works great and the typeahead suggest works great as well.
The problem is that on the server, the call to populate the datatable is pretty heavy. So I assume, each time a user types something, there is a round trip to the server, my heavy call populates the datatable, your control then selects what is needs from the datatable and that is passed back to the control on the web form. For my senario, this is not very practical.
Is there any way to avoid these heavy round trips without having to hand code the whole thing in js?
Thanks for the help
Zack
Hi Zack,
What kind DataSource are you using? I guess it's loading all the records in the server side. The WebCombo tells the DataSource to retrieve only the first 20 rows that match the filter, but if the DataSource does not honor that, the filtering is done in the server by the WebCombo.
Tony wrote an article on how to enable paging using ObjectDataSource and TableAdapter. If you use the ASP.NET 3.5 LinqDataSource you will get that behavior automatically. In both cases the DataSource will just load that page from the database.
Regards,
Andres
Hi Andres,
Thanks for that, I am using a ObjectDataSource that is bound to a DataTable that is translated from a Array of Objects(Clients) that is returned from a service - so if I understand you correctly, I need to implement filtering and sorting, as well as the SelectCountMethod on the datasource (with a signature the same as SelectMethod). So the control will use those method calls on the ObjectDataSource, I need to match those in the service layer, so I won't be killing my server. I will give it try and revert.
Thanks
Here there is another sample http://www.unboxedsolutions.com/sean/archive/2006/01/21/843.aspx.
However, if the data is returned from a service, you'll want the service to just return one page. If not, the whole array of objects will be loaded anyway.
You can also try skip the DataTable step and bind directly to the array of objects, unless you have another reason to use the DataTable.
Andres Aguiar"] You can also try skip the DataTable step and bind directly to the array of objects, unless you have another reason to use the DataTable.
Hi Andres,I have come full circle on this. I have one issue that I need to resolve to get my combo working properly. The problem I have now, is when the user types in the combo, which is editable. The suggest typeahead only returns the matching rows in the current page of data. To deal with this I want to hook into an event on the server side which will allow me to control the Select(startIndex, MaxRows) and SelectRowCount() to allow only the filtered rows to be returned to the webcombo. I have tried to hook in the objectdatasource events but only the Selecting event fires. So I must assume that the filtering is done client side in javascript or some other way as I can't seem to track where this actually happens?
I also thought that is might be calling Select methods on the DataTable / DataSet with the filter?Many thanks
You need filter the rows before returning the collection from the Select method. To do that, I think you will need to set a parameter in the DataSource that points to the WebCombo, and then access that in the DataSource methods, and use the value to filter the rows. I'm not sure how to achieve that with the approach described in the article I pointed to. I'll take a look at it and let you know.
The webcombo in the client will try filtering the rows anyway, but if you load the right rows in the server that shouldn't matter.
Try
<asp:ObjectDataSource ID="objectDataSourceOrders" runat="server" EnablePaging="True"SelectMethod="Select" TypeName="OrderDataSource"SelectCountMethod="SelectCount"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="character" PropertyName="Text" Type="String" /> </SelectParameters></asp:ObjectDataSource>
And then change the Select method to:
public OrderCollection Select(string character, int maximumRows, int startRowIndex)
This line: <asp:ControlParameter ControlID="TextBox1" Name="character" PropertyName="Text" Type="String" />
should have the ControlID pointing to the WebCombo control, and the Name tothe name of the first parameter in the Select method.
In the Select method, you need to skip the "startRowIndex" rows that start with "character", and then load the next "maximumRows" rows that start with "character".
Thanks Andres, will give that a go.There is also an issue with filtering being case sensitive? Is there anyway to avoid this?
ThanksZack
Hi, has anyone figured out how to disable/cancel client-side filtering on the webcombo?
Not yet. I had thought of some how hooking to the selectWhere() client side event and cancelling the filtering on the client side. That will be my next try when I come to it. Take a look at this post, this is where I got the idea from.
http://forums.infragistics.com/forums/t/2841.aspx
I need same functionality: be able to turn off webcombo filter and rely only on datasource select filter.
Any solution for this problem?
Thank you,
Dmitri
That is working very well now; My combo is calling my service layer and implementing paging, sorting and filtering and the service calls and SQL calls are all light and fast only return the rows that they should.Is there a way to stop the combo from doing its own filtering, but give the same behaviour as when using ComboTypeAhead = Suggest?
I would then be able to use better filtering (so no case sensitivity, use CONTAINS keyword at the back end etc)?
Thanks for your help