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
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
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
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
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