3.2.0

data Island help Alex

Hey,
I am learning a lot playing with this xml adPersistXML
data islands. I am having one major prolbem though.
When the recordset returns a null value, the xml attribute is not created, and the AW Grid will bump the next columns data over to the wrong column.

Any way for active widgets to know when an attribute is null, and just put in an empty string?

I realize I can do stuff at the query level to fix this, but We are planning on using the grid on a lot of pages, and my boss does not want us to have to reformat all the queries.
Jim Shaffer
October 26,
Any Ideas Anybody???
Jim Shaffer
October 26,
Jim,

if your data has irregular structure you can specify XPath expression for each column

//	set columns XPath
table.setColumns(["ticker", "name", "mktcap", "sales", "employees"]);


Complete example:

<html>
<head>
    <title>ActiveWidgets Grid :: Examples</title>

    <!-- 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 -->
    <style>
        .aw-grid-control {height: 150px; width: 100%; font: menu;}
    </style>
</head>
<body>
    <xml id="xmlDataIsland">
        <companies>
            <company>
                <ticker>MSFT</ticker>
                <name>Microsoft Corporation</name>
                <mktcap>314,571.156</mktcap>
                <sales>32,187.000</sales>
                <employees>55000</employees>
            </company>
            <company>
                <name>Oracle Corporation</name>
                <mktcap>62,615.266</mktcap>
                <sales>9,519.000</sales>
                <employees>40650</employees>
            </company>
            <company>
                <ticker>SAP</ticker>
                <sales>8,296.420</sales>
            </company>
        </companies>
    </xml>
    <script>

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

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

    //	set columns XPath
    table.setColumns(["ticker", "name", "mktcap", "sales", "employees"]);

    //	provide data XML
    table.setXML(xml);

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

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

    obj.setColumnCount(5);
    obj.setRowCount(3);

    //	provide column labels
    obj.setHeaderText(columns);

    //	provide external model as a grid data source
    obj.setCellModel(table);

    //	write grid html to the page
    document.write(obj);

    </script>
</body>
</html>

Alex (ActiveWidgets)
October 26,
With XPath you can display node attributes or even complex search results :-)

Attributes example:

<xml id="xmlDataIsland">
    <companies>
        <company ticker="MSFT" name="Microsoft Corporation">
            <mktcap>314,571.156</mktcap>
            <sales>32,187.000</sales>
            <employees>55000</employees>
        </company>
        <company ticker="ORCL" name="Oracle Corporation">
            <mktcap>62,615.266</mktcap>
            <sales>9,519.000</sales>
            <employees>40650</employees>
        </company>
        <company ticker="SAP" name="SAP">
            <sales>8,296.420</sales>
        </company>
    </companies>
</xml>


The XML above can be linked with the following set of XPaths:

//	set columns XPath
table.setColumns(["@ticker", "@name", "mktcap", "sales", "employees"]);
Alex (ActiveWidgets)
October 26,
Awesome, thanks My Brother.
Jim Shaffer
October 26,
And how can I separate "/companies/company/sales" and "/companies/salesman/sales" ?
Should I specify full xpath for table.setColumns([....]); ?
Andrew V.
June 28,
Use setRows() to specify XPath for the row nodes -

table.setRows("company");

or

table.setRows("//company");

The column XPath is executed relative to the row node, so it would still be

table.setColumns(["sales", ...]);
Alex (ActiveWidgets)
June 28,
Thanks
Andrew V.
June 28,
I am facing issue with row count. The xml is retrieved as a String object from a JSP. When i use

data <- from JSP
var obj = new AW.UI.Grid;
obj.setHeaderText(myHeaders);

//create ActiveWidgets data model - XML-based table
var table = new AW.XML.Table;
table.setXML(data);
obj.setCellModel(table);
obj.setColumnCount(4);

//it wont work with out the row count
//obj.setRowCount(1000); <- [b]issue[/b]


If i dont specify the row count, the data will not be displayed in the grid. Is there a way that i can set the row count. I've tried
obj.getRowCount(); with no luck.
Raj Nair
June 28,

This topic is archived.

See also:


Back to support forum