:: Forum >>

Grid Row ID problem

When I use the syntax as described in http://www.activewidgets.com/javascript.forum.7821.6/assigning-my-own-rowid-to.html, Internet Explorer returns an syntax-error. The grid doesn't load because of this error.

This is the code:
var myData = [];
    
    myData["111"] = ["MSFT","Microsoft Corporation", "314,571.156", "32,187.000"];
    myData["222"] = ["ORCL", "Oracle Corporation", "62,615.266", "9,519.000"];
    myData["333"] = ["SAP", "SAP AG (ADR)", "40,986.328", "8,296.420"];
    myData["444"] = ["CA", "Computer Associates Inter", "15,606.335", "3,164.000"];
    myData["555"] = ["ERTS", "Electronic Arts Inc.", "14,490.895", "2,503.727"];
    
];
        
    // create ActiveWidgets Grid javascript object
    var grid = new AW.UI.Grid;
    grid.setStyle('width','99.5%')
    grid.setStyle('height','350px')
    grid.setVirtualMode(false);

    // provide cells and headers text
    grid.setCellText(myData);
    grid.setHeaderText(myColumns);

    grid.setRowIndices(["111"]);
        
    // define data formats
    var str = new AW.Formats.String;
    var num = new AW.Formats.Number;
    var dat = new AW.Formats.Date;
    
    dat.setTextFormat("dd-mm-yyyy")

    grid.setCellFormat([str, str, str, str, dat, dat, str, str, str, str]);
    
    // set number of rows/columns
    grid.setColumnCount(9);
    grid.setRowCount(<%=i%>);

    // set headers width/height
    grid.setHeaderHeight(20);
    
    // set editable on/off
    grid.setCellEditable(false);
    
    // enable row selectors
     grid.setSelectorVisible(true);
     grid.setSelectorWidth(30);
     grid.setSelectorText(function(i){return this.getRowPosition(i)+1});
    
    // set row selection
     grid.setSelectionMode("single-row");


    document.write(grid);


I'm using the yesterday released version 2.0. What's wrong?
Laurens
Thursday, February 2, 2006
Found it. It was the accidentally placed ]; after the myData definition.
Laurens
Thursday, February 2, 2006
Do you provide indices for all rows? Is RowCount correct? The example above should look like

grid.setRowIndices(["111", "222", "333", "444", "555"]);
grid.setRowCount(5);


Also note that index could contain only digits (0-9), other characters are not allowed.
Alex (ActiveWidgets)
Thursday, February 2, 2006
ok, too late :-)
Alex (ActiveWidgets)
Thursday, February 2, 2006
Thanks for your fast reply! But... there is another problem. I used to fill the myDate array without row ID's:

var myData =
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000"],
etc.


I could select a row and activate a function when doing so. Now I use the other format (with Row ID's) I can't select a row anymore by clicking on it! I use the following function:

// on select row open record
    grid.onSelectedRowsChanged = function(row){
        nr = grid.getCellValue(1,row)
        ajax_details(nr)
    }



Last but not least... can you please hava a look at my other post?

http://www.activewidgets.com/javascript.forum.11247.0/great-job-but-one-little.html
Laurens
Thursday, February 2, 2006

This topic is archived.


Back to support forum

Forum search