Reference to Grid by its Id

How can I get a reference to a grid knowing only its id?

If you have worked with Dojo, something analogous to dojit.byId();


There is no such locator available, constructor of component returns reference to the object, which may be used for all further operation.
The next code may work ( but not in all cases, based on the way , how grid initialized )
var obj = document.getElementById(“gridbox”).grid;

Thanks for the answer!

I finally iused the reference the constructor gave me, as you suggested.

I want a grid and 4 comboboxes underneath it, whose values are updated each time a row is selected in the grid.

The way I am doing it now (which may NOT be correct), I have to define the 4 combos, and THEN attach the event to the grid, which takes place 30 lines of code later than the actual grid definition. Another problem is that I have to pass 4 arguments (one combo reference for each combo) to the function that is executed when the onRowSelect event occurs, which makes it more confusing.

 It would be convenient to have a get-reference-by-id mechanism, so that events can be defined anywhere, and methods are free of large numbers of object-referencing arguements.

If the procedure I followed is not the best (very likely :slight_smile: ) please suggest the correct one.

and THEN attach the event to the grid
The event can be attached at any moment ,so it must not cause any problems.

As far as I can understood, your code may look as
mygrid = new …
… some other code …
var combo1 = new dhtmlXCombo(…
var combo2 = new dhtmlXCombo(…
var combo3 = new dhtmlXCombo(…
var combo4 = new dhtmlXCombo(…

//here , the code which need to be called
// combo1 - combo4 - can be used as combo objects
// this - will point to the grid

combo1.setComboValue(this.cells(id,0).getValue); //for example