3.2.0

onSelectedRowsChanged Bug in 2.0.1?

Hi All,

I'm having a issue in 2.0.1 that I can't seem to find in the forums. The issue is when you have two grids on a page, and the first grid has an onSelectedRowsChanged function that changes the selection in the second grid, the first grid does not display its selection correctly.

Here is how to reproduce the error:

1. Create a page with 2 grids both with selection mode single-row.
obj.setSelectionMode("single-row");
       	obj2.setSelectionMode("single-row");


2. Create an onSelectedRowsChanged function on the first grid to set the selection on the second grid.
obj.onSelectedRowsChanged = function() { obj2.setSelectedRows([0]);  };


3. Select different rows in grid 1.


Here is a full example:


<html>
<head>
    <title>ActiveWidgets Grid :: Examples</title>
    <style> body, html {margin:0px; padding: 0px; overflow: hidden;} </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 {height: 100; width: 100%; margin: 0px; border: none; font: menu;}
        .aw-row-selector {text-align: center}
        .aw-column-0 {width:  80px;}
        .aw-column-1 {width: 200px;}
        .aw-column-2 {text-align: right;}
        .aw-column-3 {text-align: right;}
        .aw-column-4 {text-align: right;}
    </style>
</head>
<body>
    <script>
    var obj = new AW.UI.Grid;
    obj.getCellText = function (i,j) {return i + ',' + j};
    obj.getHeaderText =  function (i) {return i };
    obj.setRowCount(5);
    obj.setColumnCount(5);
    obj.setSelectionMode("single-row");
    obj.onSelectedRowsChanged = function() { obj2.setSelectedRows([0]);  };
    document.write(obj);

    </script>
    <script>
    var obj2 = new AW.UI.Grid;
    obj2.getCellText = function (i,j) {return i + ',' + j};
    obj2.getHeaderText =  function (i) {return i };
    obj2.setRowCount(5);
    obj2.setColumnCount(5);
    obj2.setSelectionMode("single-row");
    document.write(obj2);
    </script>
</body>
</html>



Any Ideas?


Mike Graessle
July 25,
Seems that needs a Timeout "break".
Try:
obj.onSelectedRowsChanged = function() { 
setTimeout(function(){ obj2.setSelectedRows([obj.getSelectedRows()]) ,0})
};
Carlos
July 25,
Carlos,

Thanks. The work around works great.
Mike Graessle
July 26,

This topic is archived.

See also:


Back to support forum