Grid with form

I have:

  1. A layout
  2. A datastore
  3. A grid in one cell of the layout sync-ed to the datastore
  4. A form in another cell with binding to the grid.

It’s all working well except for one thing. When the page is 1st displayed no row in the grid is selected and the form fields are blank. (If a row on the grid is manually selected it displays the correct data.)

How do I either:
a. Force the grid to select the first row? Tried mygrid.selectRow(0) but that doesn’t seem to do anything.
b. Hide the form until a grid row is selected. Can hide items on the form but not the form itself.

a. Force the grid to select the first row? Tried mygrid.selectRow(0) but that doesn’t seem to do anything.

Please, make sure that the you are selecting the row after the data is loaded to the grid.
You may use the onXLE event or a callback function of the load() method:

mygrid.load("data.xml",function(){ mygrid.selectRow(0) })

The grid is getting data from a data store:

mygrid.sync(mydatastore);

Tried placing the mygrid.selectRow(0) after that - no row selected.

Tried mygrid.setCursor(0) after binding the form to the grid - as suggested docs.dhtmlx.com/datastore__bindi … store.html

Also tried attaching an “onDataReady” event to the grid - that event does not seem to get triggered.

So far not been able to get the grid to select a row via script.

How about the other alternative of hiding the form?

Ok,found a way to hide the form…

In my case I have the grid and the form in separate cells in a layout. Layout views can be used to hide/show the form as required…


myform.bind(mygrid);
mylayout.cells(“b”).showView(“blank”); // “blank” can be any other content or nothing
// Here, “blank” is not defined so cell shows nothing

// Now show the form in the cell if a row in the grid is selected
mygrid.attachEvent(“onRowSelect”, function(id){
mylayout.cells(“b”).showView(“def”);
// “def” view is default view set up when form was attached to layout cell earlier
});

DHTMLX 4 is an excellent suite of software. The more I find out the more impressed I am.