Sets or retrieves the text in the grid cells. The text is assigned to the individual cell or to the array of cells depending on the type and the number of arguments in the setCellText() method (see the examples below).
Does not encode the html controls characters (<, >, ", &) - the text containing correct html markup will be displayed as html.
This is a faster method than using cell data property because the text is inserted into the grid cells as is without any transformations. However using the cell data property together with the cell format converter allows processing the data before display, for example, encoding the text strings or applying specific date or number formats.
When the cell content is assigned through the cell text property - the cell format converter can be used to provide reverse transformation (textToValue) for the correct sorting of the grid rows.
During the editing the cell text property is continuously updated (on each keystroke, copy/paste or drag-n-drop event). Each text change triggers onCellTextChanging and onCellTextChanged events which can be used to check or modify the entered text.
var value = obj.getCellText();
obj.setCellText(value);
obj.onCellTextChanging = function(value){...};
obj.onCellTextChanged = function(value){...};
obj.onCellTextError = function(value){...};
2-d Array
var myCells = [
["Cell <i>text</i>", "123", "5/18/2004"],
["<a href='#'>More...</a>", "456", "1/12/2006"]
]
obj.setCellText(myCells); // assign cells content
1-d array (per row)
obj.setCellText(["Cell <i>text</i>", "123", "5/18/2004"], 0); // row-0
obj.setCellText(["<a href='#'>More...</a>", "456", "1/12/2006"], 1); // row-1
Function
obj.setCellText(function(col, row){return myCells[row][col]});
Single cell
obj.setCellText("Item <1>", 0, 0); // col-0, row-0
onCellTextChanging
event can be used to restrict the cell text (filter characters) during editing -
obj.onCellTextChanging = function(text, column, row){
if (text.match(/[^0-9.+-]/)){
return "error"; // prevent non-digits
}
}
Grid templates: cell
Cell model: image, tooltip, link, value, data, format, editable, state, selected
Text properties: selector, header, footer, top, bottom