:: Forum >> Version 2 >>

XML data island example (2.0b1)

Here is an example of using XML data island for 2.0b1 (IE only):

<html>
<
head>
    <
title>ActiveWidgets Grid :: Examples</title>
    <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </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 -->
    <
style>
        .
aw-grid-control {height100%; width100%; bordernonefontmenu;}

        .
aw-column-{width:  80px;}
        .
aw-column-{width200pxbackground-colorthreedlightshadow;}
        .
aw-column-{text-alignright;}
        .
aw-column-{text-alignright;}
        .
aw-column-{text-alignright;}

        .
aw-grid-cell {border-right1px solid threedshadow;}
        .
aw-grid-row {border-bottom1px solid threedlightshadow;}

    </
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>
                <
ticker>ORCL</ticker>
                <
name>Oracle Corporation</name>
                <
mktcap>62,615.266</mktcap>
                <
sales>9,519.000</sales>
                <
employees>40650</employees>
            </
company>
            <
company>
                <
ticker>SAP</ticker>
                <
name>SAP AG (ADR)</name>
                <
mktcap>40,986.328</mktcap>
                <
sales>8,296.420</sales>
                <
employees>28961</employees>
            </
company>
            <
company>
                <
ticker>CA</ticker>
                <
name>Computer Associates Inter</name>
                <
mktcap>15,606.335</mktcap>
                <
sales>3,164.000</sales>
                <
employees>16000</employees>
            </
company>
            <
company>
                <
ticker>ERTS</ticker>
                <
name>Electronic Arts Inc.</name>
                <
mktcap>14,490.895</mktcap>
                <
sales>2,503.727</sales>
                <
employees>4000</employees>
            </
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
    
var xmlnode document.getElementById("xmlDataIsland");

    
//    IE
    
if (window.ActiveXObject) {
        
xml node;
    }
    
//    Mozilla
    
else {
        
xml document.implementation.createDocument("",""null);
        
xml.appendChild(node.selectSingleNode("*"));
    }

    
//    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(5);

    
//    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)
Thursday, October 20, 2005
Fantastic,
That really helps. One problem though. When I linked to an external xml file I didn't need to specify the rowcount property. But with your example, if I don't specify it, the grid appears empty??
Any reason why?
Are there derived properties from an xml file that I am missing by using an xml island??
Jim Shaffer
Thursday, October 20, 2005
Use
obj.setColumnCount(table.getCount());
Carlos
Tuesday, October 25, 2005
Uppss ...should be:
obj.setRowCount(table.getCount());
Tuesday, October 25, 2005
Hi Alex,

Data island works on some IE browsers where as on other IE browsers it does not work.

Line:97
Char:527
Error: Object doesn't support this property or method.

Does it need something on client side in order to successfully work.

I did not into such problems when I use XML url based grids.

Regards,
Girish Khemani, Fidelity India
Sunday, August 6, 2006



This topic is archived.

Back to support forum

Forum search