Handling PageIndexChanged and Sort events on RadGrid using RadClientDataSource and Custom Paging and Sorting

0 Answers 49 Views
Top achievements
Rank 1
Mike asked on 11 Jun 2023, 01:28 PM

I have a RadGrid that I want to bind totally on the client side. I used a RadClientDataSource and it populates nicely. I have many records, so I want to use custom paging and sorting so I am only pulling 5 records at a time. When I click on a row, I have it use an ajax call from jquery to get the VirtualItemCount and use set_virtualItemCount() to set property on RadGrid.

This all seems to work okay. But when I click on a sort column or a pager item, it blanks the whole grid. What events handler can I implement on client side to handle the sort event and the PageIndexChanged event? Here is my how I am handling the row clicked event:

 function rowClick(sender, eventArgs) {
            var nodeid = eventArgs._dataKeyValues["NodeId"];
            var masterTable = sender.get_masterTableView();
            var url = "/myservice.asmx/GetRowCount";
            var params = JSON.stringify({ NodeId: nodeid });
                method: "POST",
                url: url,
                data: params,
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                .done(function (msg) {
and here is how I handle the parameter mapping event:
   function ParameterMap(sender, args) {
        if (args.get_type() == "read" && args.get_data()) {
            var skip = window.pageSize * window.pageIndex;
            var take = window.pageSize;
            var params = { NodeId: window.nodeId, Skip: skip, Take: take, SortExpression: window.sort};
            var paramstr = JSON.stringify(params);

Attila Antal
Telerik team
commented on 14 Jun 2023, 02:37 PM

Hi Mike,

Can you please share the rest of the implementation (RadGrid, RadClientDataSource in case this is used for binding data through WebService) so we have an idea of how everything is done?

I look forward to hearing from you.

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question