:: Forum >>

Setting Format of some column to AW.Formats.Number on xml based grid do not format the cell data in those columns

Hi Alex

I am trying to set the format of a column to AW.Formats.Number and formatting the data with the following :

var cellFormatter2 = new AW.Formats.Number;

This I am doing for second column. and using xml Model to receive data from remote server that exports data as xml stream.

I am not able to see my data formatted as 222,223,445,666

Can u help me out to resolve this issue.

Vikramaditya Garg
Vikramaditya Garg
Thursday, August 3, 2006
The format should be "#,###." for zero decimals

var cellFormatter2 = new AW.Formats.Number;
Alex (ActiveWidgets)
Thursday, August 3, 2006
Hi Alex

I really appreciate your response.
Everything seems to be fine.Now after applying the formatting and making those cells uneditable , we are trying to sort the data for that particular column but the sorting breaks now.

I have tried to set the text in on cell using onCellEditStarted event and reapplied the formatting on onCellEditEnded event but the sorting still breaks.

I have found that If I change column "Employees" with values 10 100 and 12 and then do sorting ...it breaks.. but if i edit three cells of employee and give values as 010 100 012 .The sorting runs perfectly fine.It seems that there is some inconsistency between text,data,value
I am attaching you the sample code .Please help us to resolve the issue.

/********** Code starts Here ***************/
<title>ActiveWidgets Grid :: Edit And Sort</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>

<!-- ActiveWidgets stylesheet and scripts -->
<link href="runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="runtime/lib/aw.js"></script>

<!-- grid format -->
.aw-grid-control {height: 100%; width: 100%; margin: 0px; border: none; font: menu;}
.aw-row-selector {text-align: center}

.aw-column-0 {width: 80px;}
.aw-column-1 {width: 200px;}
.aw-column-2 {text-align: right;}
.aw-column-3 {text-align: right;}
.aw-column-4 {text-align: right;}

.aw-grid-cell {border-right: 1px solid threedlightshadow;}
.aw-grid-row {border-bottom: 1px solid threedlightshadow;}

<!-- grid data -->

var myColumns = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"


// create ActiveWidgets data model - XML-based table
var table = new AW.XML.Table;

// provide data URL

// start asyncronous data retrieval

table.setData = function(value, col, row){
var node = this.getNode(col, row);
if (AW.ie) {
node.text = value;
else {
node.textContent = value;

// create ActiveWidgets Grid javascript object
var obj = new AW.UI.Grid;

// define data formats
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
var floatFormat = new AW.Formats.Number;
obj.setCellFormat([str, str, floatFormat, floatFormat,num]);

// provide cells and headers text

// set number of rows/columns

// enable row selectors
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

// set headers width/height

// set row selection


// set click action handler
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};

// assign external 'data model'

// write grid html to the page

obj.onCellEditStarted = function(text, col, row){

obj.onCellEditEnded = function(text, col, row){
//alert("data :" + obj.getCellData(col,row));
//alert("con text :" + this.getCellFormat(col, row).dataToText(text));
obj.setCellText(this.getCellFormat(col, row).dataToText(text),col,row);

obj.onKeyCtrlC = function(event){
var c = this.getCurrentColumn();
var r = this.getCurrentRow();
//copyToClipBoard(removeCommas(this.getCellText(c, r)));
copyToClipBoard("Text : " + this.getCellText(c, r) + " Data : " + this.getCellData(c, r) + " Value : " + this.getCellValue(c, r));
AW.setReturnValue(event, false); // prevent default

/****** Copies text to system clipboard *****/
function copyToClipBoard(text) {
if (window.clipboardData) {
// the IE-manier
window.clipboardData.setData("Text", text);
return false;

/********** Code ends Here ***************/

The contents of companies-simple.xml are

<name>Microsoft Corporation</name>
<name>Oracle Corporation</name>
<name>SAP AG (ADR)</name>
<name>Computer Associates Inter</name>
<name>Electronic Arts Inc.</name>
<name>Softbank Corp. (ADR)</name>
<name>Veritas Software Corp.</name>
<name>Symantec Corporation</name>
<name>Infosys Technologies Ltd.</name>
<name>Intuit Inc.</name>
<name>Adobe Systems Incorporate</name>
<name>PeopleSoft, Inc.</name>
<name>Siebel Systems, Inc.</name>
<name>BEA Systems, Inc.</name>
<name>Synopsys, Inc.</name>
<name>Check Point Software Tech</name>
<name>Mercury Interactive Corp.</name>
<name>Amdocs Limited</name>
<name>Citrix Systems, Inc.</name>
<name>Konami Corporation (ADR)</name>
Vikramaditya Garg
Friday, August 11, 2006
This issue occurs with editable cells.
Vikramaditya Garg
Vikramaditya Garg
Friday, August 11, 2006
the response is still awaited...
Please some help us as the problem is critical to us
Vikramaditya Garg
Vikramaditya Garg
Sunday, August 13, 2006

This topic is archived.

Back to support forum

Forum search