:: Forum >>

HTML INPUT tags in grid control built from XML data island

We embed HTML INPUT tags in the XML used to generate the grid. When the grid is sorted, all the checkboxes are revert to their initial value. I assume this happens because the grid reloads the original XML data, restoring the checkboxes to their initial state.

Is that a correct analysis?

Is there a way to alter this behavior so that the checkboxes preserve their state when a sort occurs?

The example below reproduces the problem. It is a slight modification of the example distributed with ActiveWidgets:
\examples\grid\xml - data island.htm

    <title>ActiveWidgets Grid :: Examples</title>
    <style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>

    <!-- ActiveWidgets stylesheet and scripts -->
    <link href="../../runtime/styles/classic/grid.css" rel="stylesheet" type="text/css" ></link>
    <script src="../../runtime/lib/grid.js"></script>
function showSelections () {
    var checks = document.getElementsByName("selectedCorp");
    if ((typeof(checks) != "undefined") && (checks.length > 0)) {
        var message = "gridForm: checks.length=" + checks.length + " [";
        for (var i=0; i < checks.length; i++ ) {
            if (checks[i].checked) {
                message += " " + checks[i].value;
        message += " ]";
        window.status = message;

    <!-- grid format -->
        .active-controls-grid {height: 100%; font: menu;}

        .active-column-0 {width: 80px;}
        .active-column-1 {width: 200px; background-color: threedlightshadow;}
        .active-column-2 {text-align: right;}
        .active-column-3 {text-align: right;}
        .active-column-4 {text-align: right;}

        .active-grid-column {border-right: 1px solid threedshadow;}
        .active-grid-row {border-bottom: 1px solid threedlightshadow;}
<form name="gridForm" onsubmit="showSelections();">
<table style="height:70%;table-layout:fixed;"><tr><td>
    <xml id="xmlDataIsland">
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='MSFT' /&gt;MSFT</ticker>
                <name>Microsoft Corporation</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='ORCL' /&gt;ORCL</ticker>
                <name>Oracle Corporation</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='SAP' /&gt;SAP</ticker>
                <name>SAP AG (ADR)</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='CA' /&gt;CA</ticker>
                <name>Computer Associates Inter</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='ERTS' /&gt;ERTS</ticker>
                <name>Electronic Arts Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='SFTBF' /&gt;SFTBF</ticker>
                <name>Softbank Corp. (ADR)</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='VRTS' checked /&gt;VRTS</ticker>
                <name>Veritas Software Corp.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='SYMC' /&gt;SYMC</ticker>
                <name>Symantec Corporation</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='INFY' /&gt;INFY</ticker>
                <name>Infosys Technologies Ltd.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='INTU' /&gt;INTU</ticker>
                <name>Intuit Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='ADBE' checked /&gt;ADBE</ticker>
                <name>Adobe Systems Incorporate</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='PSFT' /&gt;PSFT</ticker>
                <name>PeopleSoft, Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='SEBL' /&gt;SEBL</ticker>
                <name>Siebel Systems, Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='BEAS' /&gt;BEAS</ticker>
                <name>BEA Systems, Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='SNPS' /&gt;SNPS</ticker>
                <name>Synopsys, Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='CHKP' /&gt;CHKP</ticker>
                <name>Check Point Software Tech</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='MERQ' /&gt;MERQ</ticker>
                <name>Mercury Interactive Corp.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='DOX' /&gt;DOX</ticker>
                <name>Amdocs Limited</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='CTXS' /&gt;CTXS</ticker>
                <name>Citrix Systems, Inc.</name>
                <ticker>&lt;input type='checkbox' name='selectedCorp' value='KNM' /&gt;KNM</ticker>
                <name>Konami Corporation (ADR)</name>

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

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

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

    // provide data XML

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

    // create ActiveWidgets Grid javascript object
    var obj = new Active.Controls.Grid;

    // provide column labels
    obj.setColumnProperty("texts", columns);

    // provide external model as a grid data source

    // write grid html to the page

<table style="height:30%"><tr><td>
<tr><td colspan="2">
<li>Select and de-select some checkboxes.</li>
<li>Press <b>Show Selections</b> and the values of the selected checkboxes appear in the browser status line, below.</li>
<li>Sort the grid by clicking a column header. The selections are set to their initial value.</li>
<li>Figure out how to preserve the selections and post your brilliant solution to this problem.</li>
    <input type="button" value="Show Selections" onclick="showSelections();">
    <input type="submit" value="Submit">
Wednesday, May 25, 2005
Does anyone have an answer?

Even if the answer is "You are doing something that the grid control doesn't support well" that's better than no answer at all.

Is there a problem embedding HTML controls in the XML? Should we be looking at a different approach?

Is there a way to write the 'checked' state of the checkboxes back into the XML before the sort occurs?

Is there a way to prevent the data grid from clearing the checkboxes when a sort occurs?

Are there other options available to us?

Any input is appreciated
Thursday, May 26, 2005

This topic is archived.

Back to support forum

Forum search