Add Row Button with multiple grids - get grid object?


I have a grid working by itself, but am trying to get multiple grids working on the same page together now. I found out I could refer to a specific grid using ‘this’ in attached event functions, but my problem is implementing a button to Add a New Row.

I used to say

[code]Add New Row

function addRow() {
var newId = (new Date()).ValueOf();
mygrid.addRow(newId, [’’,’’]);

But now, since there are multiple grids I can’t use “mygrid”.

Any ideas on how I can reference a grid from a standard function like that? I tried something like this with no luck:

[code]<a href=’#’ onclick=‘addRow(‘gridcontainerid’);’>Add New Row

function addRow(gridid) {
mygrid = new dhtmlXGridObject(gridid);
var newId = (new Date()).ValueOf();
mygrid.addRow(newId, [’’,’’]);

but that didn’t seem to work.

I am creating the grids dynamically with server side code and don’t know how many there will be, so I’m hoping there is a way to “get” a certain grid by the DIV ID or anything else, and manipulate it.


You should pass necessary grid object as parameter of addRow() function:

[code]var grid1; //global variables
var grid2;

Add New Row[/code]