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

[Solved] Getting FilterExpression Client-Side

1 Answer 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Graham asked on 21 Jun 2009, 01:09 PM
hi,

I need to be able to extract the SQL FilterExpression from a radgrid on the client-side.  On clicking a button, I have a javascript function which should get the filter expression as an SQL string and then send it to a new window through a URL.

The new window then takes the FilterExpression from the URL and applies it to a new radgrid on the server side. This is for a "print friendly" version of the grid.

My javascription function is called from a client-side button click handler and looks like:

 

function PrintRadGrid() {

 


var
ClientsGrid = $find("<%=ClientsGrid.ClientID %>");

 

 

 

 

 

 

var f = ClientsGrid.get_masterTableView().get_filterExpressions().toString();

 

 

 

var previewWnd = window.open('print/Clients.aspx?Filter=' + escape(f), '', '', false);

 


previewWnd.print();

 

 

 

 

 

}

Problem is that the filter variable is always blank and I cannot get the SQL expression I need.

Any ideas?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 24 Jun 2009, 03:38 PM
Hello Graham,

You can save your filter expression into a hidden input on the server:

<input type="hidden" id="gridFilterExpression" runat="Server" /> 

void RadGrid1_PreRender(object sender, EventArgs e) 
    gridFilterExpression.Value = RadGrid1.MasterTableView.FilterExpression; 

Now you can get to your filter expression from any part of your  javascript:

var expr = document.getElementById('<%= gridFilterExpression.ClientID %>').value; 
alert(expr); 


Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Graham
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or