Issue with datagroupgrid with treegrid


#1

I am not able to get the treegrid grouped
I am using dhtmlx connector withtreegridgrouped connector
The controller code is given below: (I want the grouping by ag cell

   $tconn = new TreeGridGroupConnector($mysqli, "MySQLi");
   $tconn->configure("dummy", "rqid", "ag,rq,rqid,agid","","ag"); 
   $tconn->useModel(new AGLModel());
   $tconn->render();

The Model is:

[code]

class AGLModel{
function get($request){
global $db,$account;
$result = $db->query(sprintf(“SELECT agrp.title as ag,
acq.title as rq,
acq.id as rqid,
agrp.id as agid
FROM account_questions acq
LEFT JOIN a_q_grp_items agitems ON acq.id = agitems.item_id
LEFT JOIN a_q_grp agrp ON agitems.account_question_group_id = agrp.id
WHERE agrp.account_id = %d
AND agitems.item_type=‘QUESTION’”,$account->id));
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$data[] = array(‘ag’ => $row[“ag”], ‘rq’ => $row[“rq”],‘rqid’ => $row[“rqid”],“agid” => $row[“agid”]);
};
};
return $data;
}

function insert($action){
    
}
function update($action){
    
}    

}[/code]

The grid code is:

  var dpagl = new dataProcessor("/app/ajax_datavalues/<?=$account->id?>/agl"); //account group to question linker 
 dpagl.action_param = "dhx_editor_status";

        aglgrid = agLayout.cells("a").attachGrid();
        aglgrid.setHeader("Account Groups,Rating Questions,rid,agid");
        aglgrid.setInitWidths("250,*,10,10");
        aglgrid.setColAlign("left,left,left,left");
        aglgrid.setColTypes("tree,ro,ro,ro");
        aglgrid.setColSorting("str,str,int,int");
        aglgrid.enableAutoWidth(true);
        aglgrid.init();  
        aglgrid.load("/app/ajax_datavalues/<?=$account->id?>/agl/",function(){ 
        });
        dpagl.init(aglgrid);

The output I’m getting is


How do I group ‘Rating Questions’ based on its account groups using the connectors?


#2

I’m trying to get it to create a tree grid like this example in your site

https://docs.dhtmlx.com/connector__php__treegroupconnector.html

But the connector is generating a linear grid data


Any help guys how to get the data in a treegrid/tree format ?


#3

Guys any help on this please?


#4

Guys please help with this. We are not able to find any way to get data into the tree. We purchased your pro verison but the sad part is that we struggle all the time with our projects because of documentation. Can someone please let us know what is wrong in the code.


#5

Hi,

TreeGridGroupConnector requires direct DB access, it will not work with data model.
You can try to adjust get method of model like next

function get($request){ global $db,$account; if (!$request-> get_relation()){ $result = code_to_get_first_level(); //get group only } else { $group = $request-> get_relation(); $result = old_db_code($group); } if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $data[] = array('ag' => $row["ag"], 'rq' => $row["rq"],'rqid' => $row["rqid"],"agid" => $row["agid"]); }; }; return $data;

Or, which sounds as a more simple approach, just use TreeGridMultitableConnector and define a custom sql for each level of tree ( sql to select a group for top level and sql to select data based on group for second level )


#6

We purchased your pro verison

If you have a support subscription, please use support.dhtmlx.com