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

ClientSideBinding with default filter

3 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristijan
Top achievements
Rank 1
Kristijan asked on 09 Jan 2012, 01:08 PM

Dear Experts,

I am using RadGrid to implement a business application showing some tabular data which should be filtered according to the responsible user(owner).

In order to maximize the user experience I used two additional features 

The problem is that I am not able to apply default filter on initial load with client side binding. I suppose this should be possible by properly initialize the Grid’s server state that reflects on the client as filterExpressions array.

I tried the following approaches but none seems to be the right one:

I am using (DNN - RadAjax Version: 2011.2.712.35

Has anyone experience with this approach?

Any hint will be highly appreciated.

Thank you, 
Kristijan


3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 11 Jan 2012, 02:16 PM
Hello,

Applying filter expressions on Initial load is also supported scenario, however you need to make few adjustments to the code:

  • You need to add HiddenField control and based on the condition of the Page.IsPostBack property to set its value for example to "true" or "false" on the server Page_Load event.
  • Then on client pageLoad event to check what is the hidden field value and based on this value  to apply the filter expression to the desired tableview.
  • Additionally in the RadCombox client SelectedIndexChanged event for the item with text "All" you need to clear the filterExpressions collection by calling the clearFilter function.

The aforementioned steps describe pretty much everything needed to get working filter template with initial filtering and client-side binding, however I have created a sample project to illustrate this approach.

Give it a try and check whether if it is working as expected.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Kristijan
Top achievements
Rank 1
answered on 12 Jan 2012, 09:43 AM

Hi Andrey,

Thank you for your answer. Although I got not a complete answer to my problem (I need to initialize the filter with changeable date – you used a constant), it helps me to understand the required approach.

Now I understand there is no possibility to preset the filter on the server side, by setting some grid attributes, but only through the help of the hidden fields and some JavaScript on the client side. So now I am going to set the Id of the current user in another hidden field and use it as an argument in the filter function (see below).


Thank you again,

Kristijan

function pageLoad(sender, args) {
    var hdnField = $get("<%=hdnField.ClientID %>");
    var radGrid = $find("<%=RadGrid1.ClientID %>");
    var hdnUserId = $get("<%=hdnUserId.ClientID %>");
    if (hdnField.value === 'true') {
        radGrid.get_masterTableView().filter("Name", hdnUserId, Telerik.Web.UI.GridFilterFunction.EqualTo, true);
    }
}

0
Accepted
Andrey
Telerik team
answered on 13 Jan 2012, 03:33 PM
Hello,

Yes, you are on the right track with this approach. You just need to take care of changing the value of the hdnUserId control on the server and I think you will not have problems with this approach.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Kristijan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Kristijan
Top achievements
Rank 1
Share this question
or