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

[Solved] Simulating 'filter' call from asp:button

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cranialstrain
Top achievements
Rank 1
Cranialstrain asked on 22 Jan 2010, 01:00 PM
I'm using Visual Studio 2005 with the latest Telerik RadGrid component. We have disabled the AutoPostBack on the filter field and used JavaScript to intercept and stop the filter call made by the filter menu click. However we can find no way to then have a button on the page that then simulates the same call. Our attempts just won't work because the postback loses the filter details and when interrogating the grid filter values in the code-behind the select filter item is 'No Filter'.

Scenario:
1. Enter various filter values in columns and select the filter type from menu.
2. Click button that's posts back this detail and allows us to construct SQL to query on all column values.

We have tried a variety of options none of which seems to work (in VS2005 at least), can anyone point us in the right direction? Preferably with a detailed code example? You're help would be greatly appreciated!

CS. 

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 26 Jan 2010, 11:47 AM
Hi Cranialstrain,

To simulate a filter command fired from the button, you can take two approaches:

1. Attach an event handler to the client click event of the button, find the client object of the grid, get a reference to the master table view ($finid('<%=RadGrid1.ClientID%>').get_masterTableView()) and use the latter's filter method to trigger the filter command as described in the following help article:
http://www.telerik.com/help/aspnet-ajax/grid_filter.html

2. Another approach is to attach a server handler to the button's click event, and handle the filtering on the server by using the MasterTableView's FilterExpression property or the FireCommand  method that is supported by each item in the grid:
http://www.telerik.com/help/aspnet-ajax/grdfirecommandeventfromcode.html

If you need the filter value and the filter functions used by the filtering to appear in the filtering row - just update the corresponding column's CurrentFilterValue and CurrentFilterFunction properties accordingly.

I hope this information helps.


Best wishes,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Cranialstrain
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or