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

Clientside row select - w/o set_selected()

4 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Pullella
Top achievements
Rank 1
Michael Pullella asked on 01 Jun 2010, 02:18 PM
Hi

Is there a way to set the display of a grid row to look as if it is selected without using set_selected()?

I have a grid which I am populating on the client.  When the user selects a row, I am populating other controls via a RadAjaxPanel (therefore a postback).  When the control finishes the postback, the row is no longer selected, so I am storing the index of the row that was selected and during the RadAjaxPanel_OnResponseEnd, I am attempting to reselect the row using set_selected.  Works great, except that that fires the event which is causing an indefinite loop of postbacks.

I was hoping that there is a way on the client to set the style of the row to look selected without using set_selected(), hopefully avoiding the problem described above.

This gets me my selectedrow (on the client)
$find("<%= grdEntityAttributes.ClientID %>").get_masterTableView().get_dataItems()[document.getElementById("selectedRow").value] 

Any ideas?

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 04 Jun 2010, 07:51 AM
Hello Michael,

If your row selected state is not preserved on postback from the RadAjaxPanel, this means RadGrid is rebound, as rebinding clears the selected state. If you want to preserve the selection on postback, the recommended approach is to save and load the selected item state on the server side. You cana save the selected indexes before the grid is rebound and restore the state on PreRender.

If you still want to apply the selected state only, the CSS class name you need to set to your grid rows is rgSelectedRow. Note, however, that this approach is not recommended.

All the best,
Veli
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
Michael Pullella
Top achievements
Rank 1
answered on 04 Jun 2010, 11:30 AM
Thank you for the information Veli

Unfortuntatly, I am unable to bind the grid on the server as the values for the grid are all generated on the client and can't be saved to the server until the entire operation is completed.

I think the approach of setting the class to rgSelectedRow should work, but just need to know how to set it.  I tried

$find("<%= grdEntityAttributes.ClientID %>").get_masterTableView().get_dataItems()[selectedIndex].cssClass = "rgSelected" &

$find("<%= grdEntityAttributes.ClientID %>").get_masterTableView().get_dataItems()[selectedIndex].className= "rgSelected"

but neither worked.  Can you help?
0
Accepted
Veli
Telerik team
answered on 04 Jun 2010, 04:42 PM
Hello Michael Pullella,

Try with

$find("<%= grdEntityAttributes.ClientID %>").get_masterTableView().get_dataItems()[selectedIndex].get_element().className = "rgSelected"


Sincerely yours,
Veli
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
Michael Pullella
Top achievements
Rank 1
answered on 04 Jun 2010, 07:12 PM
You guys are the greatest!  Thanks!
Tags
Grid
Asked by
Michael Pullella
Top achievements
Rank 1
Answers by
Veli
Telerik team
Michael Pullella
Top achievements
Rank 1
Share this question
or