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

[Solved] OnRowSelected defect with Grid.Rebind()

1 Answer 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 10 Feb 2010, 07:36 AM
According to the documentation the OnRowSelected client event fires after the row is selected. There is a defect becuase when you call the rebind() method on the grid inside of this client side function the currently selected row (client side) is not reflected server-side.

The work around is to use the OnRowClick event instead. When calling the rebind() on the grid inside this client side function the currently selected row is properly reflected server-side.

 
        function onUserSelected(sender, eventArgs) {  
            var mTable = sender.get_masterTableView();  
            mTable.rebind(); // after this is called check the server-side needs data source event and the row currently selected client-side is not what is reflected server-side  
        }  
 
...  
 
<telerik:RadGrid ID="UsersGroupsGrid" runat="server"  OnNeedDataSource="UsersGroupsGrid_NeedDataSource">  
   <ClientSettings EnableRowHoverStyle="True">  
      <Selecting AllowRowSelect="True" /> 
      <ClientEvents OnRowSelected="onUserSelected" /> 
   </ClientSettings> 
</telerik:RadGrid> 

Thanks,
Joey

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 10 Feb 2010, 10:36 AM
Hello Joey,

Indeed, you are correct in observing this behavior and the reason for it is that by design the grid updates its client-state after the row selected event has been raised. Thus, rebind() never gives the grid the chance to update its client-sate and what is sent to the server is not updated.

However, you can easily override this behavior by calling just before rebinding the grid the updateClientState() method as follows:

function onRowSelected(sender, args)
{
    sender.updateClientState();
    sender.get_masterTableView().rebind();
     
}

I hope this helps.

Greetings,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Joey
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or