:: Forum >> Version 1 >>

2 grids interacting with each other

Hi

I have one grid full of data on which I have an action that gets the selected rows data. (TABLE1)

I have another table which is blank. (TABLE2)

When the you click on a row of TABLE1, I want it to be put into TABLE2.

Any insight/help would be appreciated.

Thx
|:{)
Jean - Charles
Tuesday, August 10, 2004

TABLE2 should be using some JS_ARRAY to populate data, if yes, then

1. you need to push the data in that array
2. set data/count
3. set row/values (you need to do this, if because values is intialized for zero rows)
4. call refresh

// assuming...
var myData2 = [];
obj2.getDataText = function(ij){return myData2[i][j]};

myData2[0] = aRow;
obj2.setDataProperty("count"1);
obj2.setRowValues([0]);
obj2..refresh();

 
Sudhaker Raj
Tuesday, August 10, 2004
Thank-you

Most helpfull :P
JC
Wednesday, August 11, 2004
Actaully not helpfull, I was just being polite :/

How do I use this ? In a function ? What is 'aRow' ?

Heres my code:
---------------
#Css/js declared etc.

var myColumns = ["contact""cellno"];
        var 
myData = [ ["David""0841234234"],["Bobby""0832443534"],
            [
"Uncle Sam""0742342344"],["Aunt Sally""0735647589"],
            [
"Stuart""0731822766"],["David Beckham""0731231234"],
            [
"Bobbi Skinstad""0731222726"],["asdasd""0832233445"],
            [
"another num""0832706668"],["chop""0731244578"],
        ];
        var 
myData3 = [
            [
"Suckass""0841234234"],["Narf""0832443534"],
            [
"Biteme""0742342344"],["Shampoodle""0735647589"],
            [
"Stuart""0731822766"],["Oli fis""0731231234"],
            [
"Naatjie""0731222726"],["lololo""0832233445"],
            [
"Zomp""0832706668"],["Afrtoz""0731244578"],
        ];

        var 
myData2 = [];

          var 
obj = new Active.Controls.Grid;

          
obj.setId("grid1");
          
obj.setColumnCount(2);
          
obj.setRowCount(10);
         
obj.setProperty("selection/multiple"true);
         
obj.setDataText(function(ij){return myData[i][j]});
          
obj.setColumnText(function(i){return myColumns[i]});
        
obj.setRowHeaderWidth("10px");
          
obj.setColumnHeaderHeight("20px");


        
//Print selected row
        
function printRowData(src){
            var 
index src.getProperty("row/index");
            
obj2.setProperty("data/text"myData[index]);
            
obj2.refresh();
        }

        
//Add a row
        
function addRow(){
            var 
rowData = ["NEW-USER""0742456431"]
            
myData.unshift(rowData);
            
obj.setRowProperty("count"myData.length);
            
obj.refresh();
        }

        
//Remove a row
        
function removeRow(grid) {
            var 
index grid.getProperty("selection/index");
            if(
index != '-1') {
                if (
confirm("Are you sure you want to delete?")) {
                    
_removeRow(gridindex);
                    var 
lastRow grid.getProperty("row/count");
                    if(
lastRow == 0addNewRow(grid);
                        
grid.setProperty("selection/index"lastRow-1);
                }
            } else 
alert('Error or something.');
        }

        function 
argh() {
            
obj2.getDataText = function(ij){return myData2[i][j]};
            
myData2[0] = aRow;
            
obj2.setDataProperty("count"1);
            
obj2.setRowValues([0]);
            
obj2.refresh();
        }

        
obj.setAction("click"argh);
          
document.write(obj);
 
Thanks
JC
Wednesday, August 11, 2004
Table no 2..
</script>
    </
td></tr><tr><td>
    <
script>
        var 
obj2 = new Active.Controls.Grid;
        
obj2.setId("grid2");
        
obj2.setRowCount(10);
        
obj2.setColumnCount(2);
        
obj2.setProperty("selection/multiple"true);
        
obj2.setDataText(function(ij){return myData2[i][j]});
        
obj2.setColumnText(function(i){return myColumns[i]});
        
obj2.setRowHeaderWidth("10px");
        
obj2.setColumnHeaderHeight("20px");
        
obj2.setAction("click"removeRow);
        
document.write(obj2);
    </
script>
    </
td></tr></tbody></table>
 
JC Again
Wednesday, August 11, 2004
Hi JC,
I have pasted the code whatever you have given.But I am getting aRow undefined.Can u please send a working copy.

Rajalakshmi
Friday, July 22, 2005



This topic is archived.

Back to support forum

Forum search