Retrieve filtered data from RadClientDataSource using RadGrid's event

1 posts, 0 answers
  1. Attila Antal
    Admin
    Attila Antal avatar
    545 posts

    Posted 17 Jan 2018 Link to this post

    Requirements

    Telerik Product and Version

    3.5+

    Supported Browsers and Platforms

    All browsers supported by Telerik UI for ASP .NET AJAX

    Components/Widgets used (JS frameworks, etc.)

    ASP.NET, JavaScript

    PROJECT DESCRIPTION 
    This sample describes the way to access the filtered results instead of the entire data when RadGrid is bound to RadClientDataSource. It could also be a viable workaround for the issue reported as Grid with RadClientDataSource sends two requests when navigating with Grid pager.

    Create a RadClientDataSource control and set its EnableServerFiltering property to True.
    <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server" EnableServerFiltering="true">
        <DataSource>
            <WebServiceDataSourceSettings ServiceType="OData">
                <Select Url="http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders" DataType="JSONP" />
            </WebServiceDataSourceSettings>
        </DataSource>
    </telerik:RadClientDataSource>

    Create a RadGrid, set the ClientDataSourceID property's value to the ID of the RadClientDataSource created earlier and subscribe it to OnDataBound client event.
    <telerik:RadGrid ... ClientDataSourceID="RadClientDataSource1">
        <ClientSettings>
            <ClientEvents OnDataBound="gridBound" />
        </ClientSettings>
        <MasterTableView>
            <Columns>
                ...
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    JavaScript method to be executed when the OnDataBound event of RadGrid is fired.
    function gridBound(sender, args) {
        // access the DataSource object bound to grid
        var clientDataSource = $find(sender._clientDataSourceID);
        // Access the Kendo widget
        var widget = clientDataSource.get_kendoWidget();
        // Access the filtered data from the data source
        var result = widget._pristineData;
         
        // process the "result"
    }


Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.