Hi,
I have a grid in which I have to restrict the user from selecting few rows based on some column value.
I am allowing the users to select the rows by clicking on them currently.
How can I make some rows unselectable on click?
Brindavan
I have a grid in which I have to restrict the user from selecting few rows based on some column value.
I am allowing the users to select the rows by clicking on them currently.
How can I make some rows unselectable on click?
Brindavan
5 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 19 Mar 2009, 04:30 AM
Hello Brindavan,
Try the following client side code for preventing row selection based on value. Attach the handler to OnRowSelecting client side event of Radgrid.
ASPX:
JavaScript:
Thanks,
Shinu.
Try the following client side code for preventing row selection based on value. Attach the handler to OnRowSelecting client side event of Radgrid.
ASPX:
<ClientSettings> |
<Selecting AllowRowSelect="True"></Selecting> |
<ClientEvents OnRowSelecting="RowSelecting" /> |
</ClientSettings> |
JavaScript:
<script type="text/javascript"> |
function RowSelecting(sender, eventArgs) |
{ |
var dataItem = $get(eventArgs.get_id()); |
var grid = sender; |
var MasterTable = grid.get_masterTableView(); |
var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()]; |
var cell = MasterTable.getCellByColumnUniqueName(row, "CategoryID"); |
if(cell.innerHTML == 5) //Check for the condition, here cell.innerHTML holds the value of the cell |
{ |
eventArgs.set_cancel(true); // Cancel the event |
alert ("cannot select this row"); |
} |
} |
</script> |
Thanks,
Shinu.
0
sircutbreaker
Top achievements
Rank 1
answered on 26 Jun 2012, 01:38 PM
How to make a detail table row unselectable?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Jun 2012, 02:25 PM
Hello,
Thanks,
Jayesh Goyani
function
RowSelecting(sender, args) {
if
(args.get_tableView().get_name() ==
"Child"
) {
args.set_cancel(
true
)
}
}
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
Name
=
"Parent"
>
<
Columns
>
.....................
................
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Child"
>
<
Columns
>
.............
.................
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
ClientEvents
OnRowSelecting
=
"RowSelecting"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
Thanks,
Jayesh Goyani
0
sircutbreaker
Top achievements
Rank 1
answered on 26 Jun 2012, 02:30 PM
that doesnt allow me to make a certain detail table row unselectable...
I have a column in the detail table called "Valid" if that is "False" I do not want that row to be selectable.
I have a column in the detail table called "Valid" if that is "False" I do not want that row to be selectable.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Jun 2012, 02:46 PM
Hello,
By dataKey.
By Column
Thanks,
Jayesh Goyani
By dataKey.
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Child"
DataKeyNames
=
"ID"
ClientDataKeyNames
=
"ID"
>
<
Columns
>
..................
.................
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
function
RowSelecting(sender, args) {
if
(args.get_tableView().get_name() ==
"Child"
&& args.getDataKeyValue(
"ID"
) ==
"YourcomparedValue"
) {
args.set_cancel(
true
)
}
}
By Column
function
RowSelecting(sender, args) {
if
(args.get_tableView().get_name() ==
"Child"
&& args.get_gridDataItem().get_cell(
"Name1"
).innerHTML ==
"YourcomparedValue"
) {
args.set_cancel(
true
)
}
}
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Child"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Name1"
DataField
=
"Name"
UniqueName
=
"Name1"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
Thanks,
Jayesh Goyani