Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David Hutchings on Jun 23, 2008 17:48
open dhtmlx forum
TreeGrid: Select row on initial load

We are attempting to "pre-select" a row when we initiate a treegrid object. We have tried to use the "onXLE" event to do so:

    mygrid.attachEvent("onXLE",function() {
        mygrid.selectRowById(myRowID);
    });

As well as part of the "loadXML" call:

    mygrid.loadXML("data.xml",function() {
        mygrid.selectRowById(myRowID);
    });

Both are resulting in an "Object doesn't support this property or method" error being thrown.
We are currently using a v1.5 evaluation copy (upgrading to v1.6 shortly.)

Thanks!
Answer posted by Support on Jun 24, 2008 02:52
There was no such method as selectRowById in dhtmlxgrid 1.5 ( it was introduced in dhtmlxgrid 1.6 )
You may use

mygrid.loadXML("data.xml",function() {
        mygrid.setSelectedRow(myRowID);
});
 
( the setSelectedRow has the same effect as selectRowById in dhtmlxgrid 1.5, in dhtmlxgrid 1.6 it can be used as alias for selectRowById )
Answer posted by David Hutchings on Jun 24, 2008 13:30

Thanks. We had found a solution using:

mygrid.selectRow(mygrid.getRowById(myRowID));

But the provided solution is much easier to read.