How to get the currently selected cell

Hi,

I can’t figure this out from the documentation, but I want to get a reference to the currently selected cell. Seems like it should be simple enough.

According to the docs…

grid.cells() // no args

and

grid.cellById() // no args

should both return the currently selected cell, but both infact produce errors.

So how should I do it?

I thought I could use…

var cellIndex = grid.getSelectedCellIndex();
var rowId = grid.getSelectedRowId();

but now I see no way to use the cellIndex and rowId to get the selected cell…

Can someone help?

Paul

Hello Paul,

Let’s say your DHTMLX grid object is labeled as myGrid

To reference the index of the selected cell, you’ll need to use an event and a function:

//Text colored Green is user chosen Javascript.
//Text colored Bold Black is DHTMLX API Javascript object syntax

//function to display the grid cell index

function showIndex (id, celInd) { alert(id + ", " + celInd); }

//event function to call showIndex onRowSelect

myGrid.attachEvent( “onRowSelect”, showIndex );

Selecting a row will display the index of the cell: (row, cell)