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

Client Side Re-Paging of RadGrid

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 06 Sep 2010, 05:01 PM
I have written a javascript function which filters items in a radgrid depending on options that have been specified in a listbox by the user. This worked perfectly until I added a pager, which causes there to be less items on the page than the page size states. Is there anyway of, firstly accessing all rows in a grid (client-side) when a pager is in place, and secondly, forcing re-paging of the radgrid after rows have been hidden.

the javascript method i have implemented basically does this...

 

for (var i = 0; i < masterView.get_dataItems().length; i++) {
    var aCell= masterView.getCellByColumnUniqueName(masterView.get_dataItems()[i], "aCell")

 

 

 

    if (aCell!= null) {

 

 

        var cellValue = aCell.innerHTML;

 

 

 

        if (Exists(filterListbox.get_checkedItems(), cellValue) == false) {

 

            masterView.hideItem(i);

 

            continue;

 

        }
    }
    //now re-set paging so it still displays x items instead of x-(hidden item count)
 }

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 09 Sep 2010, 05:05 PM
Hello Neil,

When RadGrid paging mechanism is enabled and the control is bound on the server, it binds itself and renders only those items that correspond to the current page index and page size of the grid. For example, if your grid source have 50 records (lets say 0-base indexed), page size is 10 and the current page index of your grid is 2, the grid will render items only for the records with indexes between 20 and 29. All other 40 items will not be rendered at all. However the grid is intelligent enough to remember the total records count that it is bound and displays that information in its pager item.

When you hide an item using the hideItem() method, the item is actually hidden on the client only (through CSS). The grid is still bound to it and that is why the pager is still counting it.

Based on that I am afraid that there is no way to:

  • Get all data source records on the client, when the grid is bound to subset of them on the server.
  • Change the items count by hiding an item using the client-side hideMethod() of the master table view.

I hope this helps.

Kind regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vsoni
Top achievements
Rank 1
answered on 15 Oct 2013, 10:26 AM
Hello everyone,

I need to select a row which is in page Index 1 by javascript.
I am using this function for selecting a row but that row is not in current page index then is it not get selected

function SetSelectedRow() {

var MasterTable = $find(rgResourceList_id).get_masterTableView();

var selectedRows = MasterTable.get_dataItems();

var selectedFiles = new Array();

MasterTable.clearSelectedItems();

for (i = 0; i < selectedRows.length; i++) {

if (selectedRows[i].get_dataItem().Id == selectID) {

contextClicked = "true"; // This change is done to hide "Paste" from context menu. From here it will go to Rowselected event.

selectedRows[i].set_selected(true);

selectID = "";

break;
}
Please help me to solve this
Thanks in advance

 

0
Konstantin Dikov
Telerik team
answered on 18 Oct 2013, 06:33 AM
Hi Vsoni,

As Martin explained in his post, such functionality could not be achieved due to the fact that when RadGrid is bound server-side, only the items in the current page are available. Furthermore, selected rows are lost on paging, unless a client-side or server-side logic is used to persist them.

Hope that clears it out.


Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Neil
Top achievements
Rank 1
Answers by
Martin
Telerik team
Vsoni
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or