:: Forum >> Version 2 >>

Bug in addRow() if datasource was empty

More information on this topic is available in the documentation section: /aw.ui.grid/addrow.html.

Here's the original example code. This works:

<script>

    var 
myData = [
        [
"row 0"0]
    ]

    var 
obj = new AW.UI.Grid;
    
obj.setCellData(myData);
    
obj.setColumnCount(2);
    
obj.setRowCount(1);
    
document.write(obj);

    function 
addRow(){
        
// calc new row index
        
var myData.length;

        
// add row to the datasource
        
myData[i] = ["row " ii];

        
// update grid
        
obj.addRow(i);
    }

    var 
button = new AW.UI.Button;
    
button.setControlText("add row");
    
button.onControlClicked addRow;
    
document.write("<br>" button);

</
script>

 
But change the declaration of myData to
var myData = [];
 
or
var myData = Array();
 
and instead of rows flowing down the grid, they flow across the grid sideways in a strage pattern.

It's taken me all morning to find the cause of this :-/

Any fix for this?
Robin
Friday, September 22, 2006
Here's a better example of it not working:

<script>

    var 
myData = [];

    var 
obj = new AW.UI.Grid;
    
obj.setCellData(myData);
    
obj.setColumnCount(10);
    
obj.setRowCount(myData.length);
    
document.write(obj);

    function 
addRow(){
        
// calc new row index
        
var myData.length;

        
// add row to the datasource
        
myData[i] = ["row " ii];

        
// update grid
        
obj.addRow(i);
    }

    var 
button = new AW.UI.Button;
    
button.setControlText("add row");
    
button.onControlClicked addRow;
    
document.write("<br>" button);

</
script>

 
Robin
Friday, September 22, 2006
Yes, this is the bug in js datasource logic - using myData=[] breaks it, so you should possibly use something like myData=[[]] and replace it with the first row.
Alex (ActiveWidgets)
Friday, September 22, 2006



This topic is archived.

Back to /aw.ui.grid/addrow.html

Documentation:

Forum search