API of DataTable allows you to retrieve existing values of cells or set new ones.
To get the record object, you should use method getItem():
Getting the record object
grid = webix.ui({
view:"datatable",
data:[ {id:"row1", title:"The Shawshank Redemption", year:"1994"} ],
...
});
...
//'record' variable will contain an object of the related DataTable record
var record = grid.getItem("row1");
//you can access data members directly
var title = record.title;
To change the current value of a cell, you should use the following technique:
Setting the cell value
record = grid.getItem(row_id);
record[column_name] = new_value;
grid.refresh();
//or
grid.updateItem(row_id, record);
Methods refresh() and updateItem() will both update the related record, while the updateItem() will also trigger saving of this record to server side, if a save script if defined.
When you work with a block of cells you can use 2 'special' methods allowing you to get values of several cells and perform some action on them:
Reversing text in the specified cells range
grid.mapCells(start_row,start_col,numRows,numCols,
function(value, row_id, column_id, row_ind, col_ind){
return value.toString().split("").reverse().join("");
});
Reversing text in all selected cells
grid.mapSelection(function(value, row_id, column_id, row_ind, col_ind){
return value.toString().split("").reverse().join("");
});
Related sample: Mapping Selection
For more on the mentioned and other related methods, see API Reference.
Back to top