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

Filtering on Radgrid on Client Side

1 Answer 612 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Chintan
Top achievements
Rank 1
Chintan asked on 01 Sep 2016, 12:58 PM

Hello Team,

I am having  simple Radgrid. which I am binding with JSON object  like below :

$(document).ready(function () {
            $(window).load(function () {
                var JSONdata = [{ "ID": 1, "FirstName": "Chintan", "MiddleName": "Mukesh", "SurName": "Dave" }, { "ID": 2, "FirstName": "Pratik", "MiddleName": "Mukesh", "SurName": "Dave" }, { "ID": 3, "FirstName": "Devang", "MiddleName": "Subhash", "SurName": "Trivedi" }]
                var tableView = $find("<%=form1.FindControl("gridClientSide").ClientID%>").get_masterTableView();
                 tableView.set_dataSource(JSONdata);
                 tableView.dataBind();
            });
        });

Grid Code :

<telerik:RadGrid  ID="gridClientSide" runat="server" AutoGenerateColumns="false" AllowFilteringByColumn="true">
                <MasterTableView TableLayout="fixed">
                    <Columns>
                        <telerik:GridBoundColumn DataField="ID" HeaderText="ID" AllowFiltering="true" UniqueName="ID"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" AllowFiltering="true"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MiddleName" HeaderText="Middle Name" AllowFiltering="true" ></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="SurName" HeaderText="Sur Name" AllowFiltering="true"></telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings>
                    <ClientEvents OnCommand="RaiseCommand"/>
                </ClientSettings>
            </telerik:RadGrid>

function RaiseCommand(sender, args) {
           
            args.set_cancel(true);

            sender.get_masterTableView().filter(sender.get_masterTableView().get_filterExpressions().getItem(0).FieldName, sender.get_masterTableView().get_filterExpressions().getItem(0).FieldValue, sender.get_masterTableView().get_filterExpressions().getItem(0).FilterFunction, true);

//sender.rebind();
        }

 

In RaiseCommand function ,  I am trying to filter radgrid by setting  filter expression nothing error occurs but no change applies in rows of grid after execution of this function.

 

Please help....Please find attached filed

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Sep 2016, 11:12 AM
Hello Chintan,

The approach that you are trying to use will not work, because such data operations are not supported with such binding. Furthermore, you are calling the filter method of the masterTableView, which will fire in an endless loop the OnCommand event of the RadGrid. I would recommend that you take a look at the implementation in the following online demo, where the data is provided to the RadGrid after each operation:
You could also take a look at the RadClientDataSource integration:


Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Filter
Asked by
Chintan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or