Render_array in treegrid (TreeGridMultitableConnector)

Hello!

I’m trying to build GridTree with arrays. Two simple assotiative arrays. But fist level in the tree is ok, but second level doesn’t show. Nothing happend if I click on the nodes.

My code is:

$connector = new TreeGridMultitableConnector(null, "PHPYii");
$connector->setMaxLevel(3);
$connector->dynamic_loading(true);

$level = $connector->get_level();


$one = [
    ['id' => '1', 'name' => 'name 1'],
    ['id' => '2', 'name' => 'name 2'],
    ['id' => '3', 'name' => 'name 3'],
    ['id' => '4', 'name' => 'name 4'],
    ['id' => '5', 'name' => 'name 5'],
    ['id' => '6', 'name' => 'name 6'],
];
$two = [
    ['id2' => '7', 'name2' => 'name 1'],
    ['id2' => '8', 'name2' => 'name 2'],
    ['id2' => '9', 'name2' => 'name 3'],
    ['id2' => '10', 'name2' => 'name 4'],
    ['id2' => '11', 'name2' => 'name 5'],
    ['id2' => '12', 'name2' => 'name 6'],
    ['id2' => '13', 'name2' => 'name 7'],
];

switch ($level){
    case 0:
        $connector->render_array($one, 'id', 'name');
        break;
    case 1:
//                $connector->render_table(new TestSubcats(), "id", "name", "", "pid");
        $connector->render_array($two, 'id2', 'name2', "");
        break;
}

And on client-side:

var grid = viewLayout.cells('a').attachGrid();

grid.setHeader('Name1,Name2,Name3,Name4,Name5,Name6');
grid.setInitWidths('*,140,100,80,*,*');
grid.setColSorting('str,str,int,na,str,str');
grid.setColTypes("tree,ro,ro,ro,ro,ro");
grid.enableAutoWidth(true);
grid.setDateFormat('%d.%m.%Y');
grid.enableAutoSaving();
grid.kidsXmlFile='index.php?r=doc/inv';

grid.reloadParty = function(partid) {
    grid.clearAll();
    grid.post('index.php?r=doc/inv', jQuery.param({
        _csrf: yii.getCsrfToken(),
        partid: partid
    }));
}
grid.init();
grid.reloadParty(partid);

grid.attachEvent("onDynXLS",function(id) {
    grid.post('index.php?r=doc/inv&id='+id, jQuery.param({ _csrf: yii.getCsrfToken(), partid: partglobal }));
});

What’s wrong in my code? if I uncoment render_table in second case (and comment render_array) - everething fine. Second level tree shows normal (from table - simple test table like array). But not from render_array().

I apologize for the delay.
You already were replied at support system.

You need to add the parent_id field in your child dataset. This field will indicarte the parent id of the child row.
YOu also need to assign this parent_id field in the render_array() function.
Here is the simplified example based on your snippet:

$two = [

    ['id2' => '7', 'name2' => 'name 1-1', 'pid' => '1'],

    ['id2' => '8', 'name2' => 'name 2-1', 'pid' => '1'],

    ['id2' => '9', 'name2' => 'name 3-1', 'pid' => '1'],

    ['id2' => '10', 'name2' => 'name 4-1', 'pid' => '1'],

    ['id2' => '11', 'name2' => 'name 5-1', 'pid' => '1'],

    ['id2' => '12', 'name2' => 'name 6-1', 'pid' => '1'],

    ['id2' => '13', 'name2' => 'name 7-1', 'pid' => '1']

];
//we can see that the data is for the parent row with id=“1”
///...
   $connector->render_array($two, 'id2', 'name2', '', 'pid');