:: Documentation >>

cell format

Sets or retrieves the data format converter for the grid cells (cell format).

The text in the grid cell is produced by applying the cell format over the cell data property. This allows encoding the html control characters (<, >, ", &) in the text strings or converting numbers and dates into specific display formats. In cases where the client-side transformation is not required the cell format can be used to convert the cell text to the cell value for the correct sorting of the grid rows.

Syntax

var value = obj.getCellFormat(); 
obj.setCellFormat(value);        

obj.onCellFormatChanging = function(value){...}; 
obj.onCellFormatChanged = function(value){...}; 
obj.onCellFormatError = function(value){...}; 

Defined in

cell model

Examples

Assign the content to the cell data and convert it with the cell formats

var myCells = [
    ["Item <1>", "1234.56", "2004-05-18"],
    ["Item 1 & 2", "9876543", "2006-02-08"]
]

var string = new AW.Formats.String;
var number = new AW.Formats.Number;
var date = new AW.Formats.Date;

number.setTextFormat("#,###.##");
date.setDataFormat("ISO8601");
date.setTextFormat("mmm d, yyyy");

var obj = new AW.UI.Grid;
obj.setCellData(myCells);
obj.setCellFormat([string, number, date]);
obj.setColumnCount(3);
obj.setRowCount(2);
document.write(obj);

Assign the content directly to the cell text and add the cell formats for the correct sorting.

var myCells = [
    ["Cell <i>text</i>", "123", "5/18/2004"],
    ["<a href='#'>More...</a>", "456", "1/12/2006"]
]

var html = new AW.Formats.HTML;
var number = new AW.Formats.Number;
var date = new AW.Formats.Date;

var obj = new AW.UI.Grid;
obj.setCellText(myCells); 
obj.setCellFormat([html, number, date]); 
obj.setColumnCount(3);
obj.setRowCount(2);
document.write(obj);

See also

Overview: using format converters
Grid templates: cell
Cell model: text, image, tooltip, link, value, data, editable, state, selected
Format properties: selector, header, footer, top, bottom

Comments

Single Quote special character handling Rob (0)
Suppress #ERR if cell is empty A. Dent (1)
Setting format for not all coloumn Fily84 (2)
How to make cell multiline Binny Singla (1)
setCellFormat Steve Childs (1)

Documentation:

Recent changes:

2.6.4
2.6.3
2.6.2
2.6.1
2.6.1
2.6.0
2.5.0 - 2.5.6
2.5.6
2.5.0 - 2.5.5
2.5.5