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

Stop row selecting on client side

3 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 05 Mar 2009, 01:45 AM
I want to stop a row from being selected on client side.

I can use RowSelecting event to do the cancel without any problem.
But it still un-higilight the currently selected row.
Is there a way to keep the current selected row as highlighted.

Shawn

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2009, 04:54 AM
Hi Shwan,

If you do not want client side row selection you may set AllowRowSelect to false and use server side row selection only. If this is not your requirement could you please explain more on your scenario.
Server-side row selection





Shinu
0
Shawn
Top achievements
Rank 1
answered on 10 Mar 2009, 12:44 AM
Here is the scenario.
- In the grid, I've turned on Client Side AllowRowSelect so that the row is highlighted when selected.
- I've also enabled rowSelected and rowSelecting
- When user click on a row, data for the selected row is populated onto an edit panel.
- User make some changes to the data in the edit panel
- Without saving the changes, user clicks on another row on the grid.
- This is when user is prompted if they want to discard the changes, if they choose no, the cancel event is set to true (see the rowselecting function).
- when this happens, the currently selected row is no longer highlighted.
- What I want to do is to keep it highlighted so that they user can see which row they are editing.

I don't want to use server-side selecting as it requires a round trip back to the server.

Below is some code snippet.

 

<telerik:RadGrid AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" ID="RadGrid1" Skin="CFSOne" EnableEmbeddedSkins="false" runat="server"

 

 

AllowSorting="true"

 

 

GridLines="None" Height="99%">

 

 

<ClientSettings>

 

 

<Selecting AllowRowSelect="true" />

 

 

<ClientEvents OnRowSelected="rowSelected" OnRowSelecting="rowSelecting" />

 

 

<Scrolling AllowScroll="true" UseStaticHeaders="true" />

 

 

</ClientSettings>

 

 

<HeaderContextMenu EnableEmbeddedSkins="False" EnableTheming="True"

 

 

Skin="CFSOne">

 

 

<CollapseAnimation Duration="200" Type="OutQuint" />

 

 

</HeaderContextMenu>

 

 

<MasterTableView ClientDataKeyNames="ProductCode"

 

 

hierarchyloadmode="Client" TableLayout="Fixed">

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="ProductCode" HeaderStyle-Width="150px"

 

 

HeaderText="Product Code" ItemStyle-Width="150px" ReadOnly="True"

 

 

UniqueName="ProductCode">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

 

</telerik:RadGrid>

And the javascript code for rowselecting and rowselect

 

 

function rowSelecting(sender, eventArgs) {

 

 

    if (true)        // simulating some changes

 

        eventArgs.set_cancel(

true); //cancel event

 

 

 

}

 

function rowSelected(sender, args) {

 

// Populated properties of the selected row into another panel.

        

 

}

 

0
Princy
Top achievements
Rank 2
answered on 10 Mar 2009, 05:37 AM
Hi,

A suggestion would be to store the row index of the edited row in a hidden field. When you choose to save the changes of the edited row , you can use this index to reset the edited row as selected( I guess you will have to do this in the true condition check in the OnRowSelecteing event).

Do let me know of further issues......

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