TreeGrid Multiconnector - Child Row Update

I have created a Treegrid using treegridmultitable_connector and attached 2 events beforeUpdate and afterInsert which is working fine for parent rows, but when i update a child row value no events are triggers. How to achieve this?

Also how do i change the coltype of only child rows to readonly?

Please provide the snippet of server side code that doesn’t work.

As for cell types, you can define default column type for readonly, and assing beforeRender handler to the connector, from which you can call for top level rows

$data->set_cell_attribute($column, "type", "ed");

Which will redefine those cells as editable ( $column - name of column field, which must be editable )

Hi Stanislav,

Following is the code snipet,

$gridConn = new TreeGridMultitableConnector($myDb->_dbcnx, “MySQL”);
$gridConn->enable_log(“log.txt”);
$gridConn->event->attach(“beforeUpdate”, “updateFunc”);
$gridConn->event->attach(“afterInsert”, “insertFunc”);

// Grid configuration
$config = new GridConfiguration();
$config->setHeader(array(“col1”, “col2”, “col3”, “col4”));
$config->setColTypes(array(“tree”, “ed”, “co”, “ro”));
$config->setColIds(array(“col1”, “col2”, “col3”, “col4”));
$config->attachHeader("#numeric_filter,#text_filter,#text_filter");

// Grid load
$level = $gridConn->get_level();

$gridConn->setMaxLevel(1);
$level = $gridConn->get_level();

switch ($level) {
case 0:
$gridConn->set_config($config);
$query = sprintf(“select * from table”);

    $gridConn->render_sql($query, "id", "col1,col2,col3,col4");
    break;
case 1:
    $queryChild = sprintf("select * from table2");
    
    $gridConn->render_sql($queryChild, "child_id", "childCol1,'','',childCol4","parent_id");
    break;

}

In the first column of type tree, parent should be editable and not the child. On the child rows, only the childcol4 should be editable. How do i achieve this. Also how to attach on update event for child rows oneditcell of col4.

If you want to have a not-editalbe tree column - it can be done only in js code, where you can have something like next

treegrid.attachEvent("onEditCell", function(stage, id){ if (this.getLevel(id) == 1) return false; return true; })

Thanks alot Stanislav. :slight_smile: