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

RadGrid client side binding and left over data

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 20 Mar 2012, 07:15 PM

The grid is based on code from a sample client side grid but I'm having a problem with data hanging around after changing pages. For this sample, assume there's 215 lines of data but the grid is set to 200 lines.  When the page changes to page 2, it correctly displays 15 lines on the screen but in the data structures that the javascript can access it sees 200 lines (which makes sense, I know the grid maintains it's original size even if it isn't showing all the lines) but all 200 lines have data bound to them (the first 15 are the new 15, the other 185 are left over from page 1).
Is it right that the extra lines on the second page still have data bound to them?  The grid seems to know to only display the first 15, how do I in my code tell which lines I should be retrieving data from for my totals?

Thanks,
Sean

 

           

function GridCommand(sender, args) {
  GetGridData(true);
}
 
function GetGridData(sendEnteredData) {
  PageMethods.GetData(currentPageIndex, tableView.get_pageSize(), sortField, sortOrder, enteredData, updateGrid, errorInCall);
}
 
function updateGrid(result) {
  var tableView = createGrid.get_masterTableView();
  tableView.set_dataSource(result);
  tableView.dataBind();
  updateTotals();
}
 
function updateTotals() {
  var items = createGrid.get_masterTableView().get_dataItems();
 
  if (items != null && items.length > 0) {
    for (var i = 0; i < items.length; i++) {
      if (items[i].get_dataItem() != null) {
        // I'm expecting only the first 15 lines would make it here if on the second page but all 200 still have data bound
      }
    }
  }
}

 

 

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Mar 2012, 04:12 PM
Hello Sean,

I am attaching a small sample based on your code that works correctly on my side. Please give it a try and let me know whether I miss something.

Regards,
Martin
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
Sean
Top achievements
Rank 2
Answers by
Martin
Telerik team
Share this question
or