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

How to change the cell of a radgrid when each cell is clicked individually?

2 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
M
Top achievements
Rank 1
M asked on 23 Feb 2014, 11:16 PM
Hi

I have a radgrid with multiple columns, I want to change the colour of a cell individually when the cell is clicked on a client side. Also, I need to capture the cell id or index and the column details and update the database.

Thanks

2 Answers, 1 is accepted

Sort by
0
M
Top achievements
Rank 1
answered on 24 Feb 2014, 12:16 AM
I've managed to click a cell by enabling the CellSelectionMode="MultiCell" and calling OnCellSelected event on a client side.

However, I 'm not able to change the colour of a cell.

Please can someone suggest?

Thanks
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2014, 03:45 AM
Hi,

Please take a look at the following code snippet to change the color of the selected cell.

ASPX:
<ClientSettings Selecting-CellSelectionMode="MultiCell">
    <ClientEvents OnCellSelected="OnCellSelected" />
</ClientSettings>

JS:
<script type="text/javascript">
 function OnCellSelected(sender, eventArgs) {
    var Rows = eventArgs.get_gridDataItem();
    var rowIndex = Rows.get_itemIndexHierarchical(); //Get index
    var columnName = eventArgs.get_column().get_uniqueName();
    var data = Rows.get_cell(columnName);
    alert(data.innerHTML); //Get the cell value
    data.style.color = "red";
  }
</script>

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