3.2.0

Help Reqd with Checkbox & XML table

All,

I am stuck at couple of places using the following code. ( to run the code below, please create an HTML page and correct the aw include files path).

Issues:
1) The Selected value of Checkbox in the result xml is coming as -1 or 0.
( please press the button to see the output)

2) First click on the checkboxes doesnt change the checked status. You have to click it two times to change the state. After that it changes the state every time you click.

3) Values changed in cells other than checkbox is not being displayed in the output xml.

Please let me know where am I going wrong.

thank you,

<html>
<head>
    <title>ActiveWidgets Examples</title>
    <script src="../../runtime/lib/aw.js"></script>
    <link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
    <style>
        .aw-alternate-even {background: #F5F5DC}
        .aw-alternate-odd {background: #E1E1CA;}
        .aw-mouseover-row {background: #F9F99C;}
    </style>
<script>

    var colsXPath = ["@checked","name","age","school","location"];
    var rowsXPath = "//person";
    var header = ["","name","age","school","location"];
    var obj = new AW.UI.Grid;
    var table = new AW.XML.Table;
    var chkTemplate = 	new AW.Templates.Checkbox


    function createGrid() {
        obj.setHeaderText(header);
        obj.setHeaderTemplate(chkTemplate, 0);
        obj.setHeaderValue(true, 0);

        obj.onHeaderValueChanged =
            function(event,index){
                if ( index == 0 ) {
                    selectAllRows(obj.getHeaderValue(index));
                }
        };

        var chkBox = new AW.Templates.Checkbox;
        obj.setCellTemplate(chkBox, 0);

        var data = document.getElementById("dataIsland").value;
        table.setColumns(colsXPath);
        table.setRows(rowsXPath);
        table.setXML(data);

        table.setValue = function (value, col, row) {
            var node = this.getNode(col,row);
            if ( node != null ) {
                node.value = value;
                obj.setCellText(value,col,row);
            }
        };

        obj.setColumnCount(5);
        obj.setRowCount(table.getCount());
        obj.setCellEditable(true);
        obj.setCellModel(table);

        var tdiv = document.getElementById("tableDiv");
        tdiv.innerHTML = obj;

    }

    function selectAllRows(bSelect) {
        var rows = obj.getRowCount();
        var table = obj.getCellModel();
        for (var i=0; i<rows; i++) {
            table.setValue(bSelect, 0, i);
        }
    }

    function showXML() {
        alert(' changed XML ->'+obj.getCellModel().getXML().xml);
    }

</script>

</head>
<body onload="createGrid()">

<div id="tableDiv" name="tableDiv"></div>

<div id="buttonDiv" name="buttonDiv">
    <input type="button" id="showXML" name="showXML" value="Show XML" onclick="showXML();"/>
</div>

<input type="hidden" id='dataIsland' name='dataIsland' value="
<persons>
    <person checked='false'>
        <name>A</name>
        <age>1</age>
        <school>Aa</school>
        <location>Aaa</location>
    </person>
    <person checked='false'>
        <name>B</name>
        <age>2</age>
        <school>Bb</school>
        <location>Bbb</location>
    </person>
</persons>"></input>
</body>
</html>
Raman
August 28,
I am really struggling with this one. I am using the version "activewidgets-2.0.1-std-developer".

any help will be greatly appreciated.
Raman
August 28,

You need to add setText method to solve your problem (3).

I dont know why the issue (1) is happening, but you could workaround it by explicitly passing true or false value in setValue method.

Also noticed that no events are fired when each checkbox is clicked. Probably Alex can help.

table.setText = function (value, col, row) { 
            var node = this.getNode(col,row); 
            if ( node != null ) { 
                node.text = value; 
            } 
        };


Raj Nair
August 29,
hey, were you able to find answer for this?
Gene
August 30,
Hello,

I am still stuck with this same issue. Can someone please help on this.
Raman
September 4,

This topic is archived.

See also:


Back to support forum