:: Forum >>

Data Type Formatting

Is there a way to format columns by applying a mask or some type of formatting?
I would like to tell the grid to display column x as currency, column y as vbShortDate etc...

Is this ability built into the grid??

If not, does anybody have any ideas on what may be the easist way to implement something like this??

I realize I can format the data before I pass it to the grid, but I am using an XML Data Island from a recordset, and I never actually loop through the data.

I have also been trying to find an xsl solution to this problem, but can't seem to find an example or tutorial that explains how to format data by data type, or even how to determine the data type for a given value.
Jim Shaffer
Monday, October 24, 2005

it is possible to format your XML data inside AW.XML.Table class. For this purpose you should create formatting objects (instances of AW.Formats.Number/Date/String class), configure them and assign to table column.

Here is complete formatting example:

    <link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
    <script src="../../runtime/lib/aw.js"></script>
        .aw-grid-control {height: 150px; width: 100%; font: menu;}
    <xml id="xmlDataIsland">
                <name>Microsoft Corporation</name>
                <name>Oracle Corporation</name>
                <name>SAP AG (ADR)</name>

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

    // fix for format index bug in 2.0b1
    table.getText = function(i, j){
        var node = this.getNode(i, j);
        var data = node ? node.text : "";
        var format = this._formats[i];
        return format ? format.dataToText(data) : data;

    // create formatting object
    var number = new AW.Formats.Number;

    // configure formatting object
    number.setTextFormat("$ #,###.#");

    // assign format to data column
    table.setFormat(number, 2);

    // get reference to the xml data island node (IE only)
    var xml = document.getElementById("xmlDataIsland");

    // provide data XML

    // define column labels
    var columns = ["Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"];

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

    // set number of rows, columns

    // provide column labels

    // provide external model as a grid data source

    // write grid html to the page


More formatting samples are here:

Alex (ActiveWidgets)
Monday, October 24, 2005

This topic is archived.

Back to support forum

Forum search