In selected data and other properties events and methods I get a rows[] object.
How do I access a certain cell in that row. Can I use the column index?
e.g. for column 2 (starting with zero) can I write: var text = rows[5][2]
?
Can I somehow get the cell by the row number and column id?
I can get the columnid from the getColumnHeaders()... but:
If you get an Array
of rows, you can access a specific row by its index and a cell by its column identifier.
Access a single row:
var row = rows[0];
Access a specific cell of the first row:
var cell = rows[0]["column-id"];
If you need access to the columns, you can request the Array
of columns via the method getColumnSettings
. See example below:
var columns = $("#grid").bootgrid("getColumnSettings");
By the way, the column Array
has the same order as the columns of your HTML table columns, because they are linked to them.
Here is the complete example:
var columns = $("#grid").bootgrid("getColumnSettings");
var firstColumn = columns[0];
var cell = rows[0][firstColumn.id];