:: Forum >> Version 2 >>

Assigning my own RowID to the Rows in V2

More information on this topic is available in the documentation section: /general.faq.releases/.

How do I give the Rows another RowID (e.g. the identity column from my database) in V2?

The method setRowValues() no longer exists in V2. This code no longer works:

var myRows = ["11111""22222""33333""44444""55555"];
obj.setRowValues(myRows);
 
Rick Jordan
Wednesday, October 12, 2005
The correct method in v2 is setRowIndices, see example in /examples/quickref/grid.htm - line 428 :-)

In beta1 row indices can only contain symbols 0-9 (numeric), the final release will allow 0-9, A-Z, a-z starting with number.
Alex (ActiveWidgets)
Wednesday, October 12, 2005
Alex

Thanks, I saw that, but I am not referring to hiding or re-ordering the rows. I am referring to setting the actual RowIDs as mentioned in this thread:

/javascript.forum.184.3/

How can we do this in V2?
Rick Jordan
Wednesday, October 12, 2005
Yes, it is the same thing - you just give the grid an array of indices to use instead of 0..(count-1).
Alex (ActiveWidgets)
Wednesday, October 12, 2005
Alex

I must be missing something . . . sorry.

setRowIndices seems to perform a completely different function to the deprecated setRowValues. Try out the code below and you will see no rows are displayed (because rows 111,222,333,444 and 555 don't exist!).


var myData = [
        [
"MSFT","Microsoft Corporation""314,571.156""32,187.000""55000"],
        [
"ORCL""Oracle Corporation""62,615.266""9,519.000""40650"],
        [
"SAP""SAP AG (ADR)""40,986.328""8,296.420""28961"],
        [
"CA""Computer Associates Inter""15,606.335""3,164.000""16000"],
        [
"ERTS""Electronic Arts Inc.""14,490.895""2,503.727""4000"]
];

var 
obj = new AW.UI.Grid;
obj.setColumnCount(5);
obj.setRowCount(5);
obj.setRowIndices( ["111""222""333""444""555"] );
obj.setCellText(myData);
document.write(obj);
 
As you say in the grid.htm example, the setRowIndices() method is used to re-arrange or hide rows, not set the RowIDs.

/********************************************************************
    re-arrange rows
********************************************************************/
    
obj.setRowIndices([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]);    // hide row 1

document.write(obj);([19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]);    // reverse order
 
This is a VERY desirable function to have, I agree, but if I could associate the RowIDs with the data IDs in my SQL database (which is what I am trying to do) then filtering the data in the grid 'on the fly' will be so easy - I simply assemble a list of data IDs using a SQL SELECT statement and pass it to the grid using setRowIndices() and voila! - I have filtered my list.

Is this a good way of doing it and if so, what method do I use to set the RowIDs because, as I have indicated, setRowIndices() doesn't seem to work the way you describe. Please advise.

Rick Jordan
Thursday, October 13, 2005
Rick,

when using custom indices you have to use them both in the grid and the data source:

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"];

var 
myColumns = ["Ticker""Company Name""Market Cap.""$ Sales"];

var 
obj = new AW.UI.Grid;

obj.setCellText(myData);
obj.setHeaderText(myColumns);

obj.setRowIndices(["111""222""333""444""555"]);

obj.setRowCount(5);
obj.setColumnCount(4);

obj.setSelectorVisible(true);
obj.setSelectorWidth(35);
obj.setSelectorText(function(i){return i});
//obj.setSelectorText(function(i){return this.getRowPosition(i)+1});

document.write(obj);

obj.onCellClicked = function(eventcolrow){
    
window.status "row: " row " column: " col;
};

 
In general, I think using cutom indices might be a very good idea if you split your application logic between client- and server-side. For example, server-side sorting or filtering would be just sending new row indices array and not the whole data set.
Alex (ActiveWidgets)
Thursday, October 13, 2005
Alex

That's incredible. This is going to make my application so much easier to write.

I appreciate it - thanks.
Rick Jordan
Thursday, October 13, 2005
My question is that this won't affect the performance? The myData array will have 5 or 555 rows?
kbazsi
Wednesday, July 19, 2006



This topic is archived.

Back to /general.faq.releases/

Documentation:

Forum search