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

[Solved] Major Problem: Grid loses SelectedItems on Client Scroll

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 19 Jun 2009, 09:47 PM
Hi All --

I've implemented a solution very, very similar to this one:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx

With a few exceptions, such as I removed the header Select All and the select/unselect command buttons.  And I'm using client scrolling instead of paging, but I am still loading all (50 or so) records at once -- no virtual scrolling or anything.

This all works perfectly as advertised...Until... I move the scroll bar on the grid up or down (even just a little) -- and on my next postback (like clicking the checkbox), I've lost all the previously selected items and only the one I just selected remains selected.

I can select all the items that are in my current scroll window just fine, but the minute I move the scroll bar, they're gone on postback.

This doesn't happen if I remove the code below:

<

 

ClientSettings>

 

 

<Scrolling AllowScroll="True" ScrollHeight="400px" UseStaticHeaders="true">

 

 

</ClientSettings>

 


And let the grid grow.

Any suggestions?

Thanks

Troy

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jun 2009, 10:22 AM
Hi troy,

I was also able to replicate a similar scenario on my end. But in my case the the CheckBox remains checked even though the Grid row selection is gone. I tried the following code to retain the Grid row selection.

CS:
 
  protected void ToggleRowSelection(object sender, EventArgs e) 
    { 
 
        ((sender as CheckBox).Parent.Parent as GridItem).Selected = (sender as CheckBox).Checked; 
 
        foreach (GridDataItem selecteditem in RadGrid1.MasterTableView.Items) 
        { 
            CheckBox checkedChkbx = (CheckBox)selecteditem.FindControl("CheckBox1"); 
            selecteditem.Selected = checkedChkbx.Checked; 
        } 
        
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Troy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or