Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






TreeGrid with json

No Tags
UserPost

09:56
17/05/2012


CrazyXoma

Member

posts 3

Hello! I read many topics here but there no answer =(

I have such problem:

1. I use treegrid in adjacency model.

2. I get the responce from the server in JSON format.

3. The struct of data such this:

Type1

- Model1

- Model2

- Model3

Type2

- Model6

- Model7

- Model8

My TreeGrid:

jQuery("#purchase_model_list").jqGrid({

url:'lib/mod_purchase_js.lib.php?ref=model_list&type_ci=".$type_ci."',

datatype: "json",

height: 285,

width: 950,

colNames:['Название','ID'],

colModel:[

{name:'name',index:'name'},

{name:'id',index:'id', width:65, align:'center', sorttype:'int'}

],

rowNum:50000,

rowTotal: 100000,

loadonce: true,

mtype: "GET",

rownumbers: false,

rownumWidth: 40,

gridview: true,

pager: '#ppurchase_model_list',

sortname: 'id',

viewrecords: true,

treeGrid: true,

treeGridModel: 'adjacency',

ExpandColumn : 'name',

multiselect: "true",

sortorder: "desc"

});


jQuery('#purchase_model_list').jqGrid('navGrid','#ppurchase_model_list',{del:false, add:false, edit:false, search:false, refresh: false});


And my server-side:

$node = (integer)$_REQUEST["nodeid"];


if( $node >0)

{

$query = "select MODEL_NO as id, MODEL_NAME as descrip

from "._TB_MODELS_."

where TYPE_NO=".$node." and is_archive=0 and CI_TYPE=1";

$sql2 = mssql_query($query) or die(mssql_get_last_message());

}

else

{

$query = "select TYPE_NO as id, TYPE_NAME as descrip

from "._TB_TYPES_."

where CI_TYPE=1 and is_real=1 and is_archive=0";

}


$sql = mssql_query($query) or die(mssql_get_last_message());


$responce->page = 1;

$responce->total = 1;

$responce->records = 10000;

$i=0;

while($row = mssql_fetch_array($sql))

{

$responce->rows[$i]['id']=$row['id'];

$responce->rows[$i]['cell']=array(iconv('cp1251','utf-8',$row["descrip"]),

$row["id"],

//'type',

$node>0?1:0,

$node>0?$node:'null',

$node>0?'true':'false',

$node>0?'true':'false',

$node>0?'true':'false'

);

$i++;

}

print json_encode($responce); exit();

My first tree grid loading (everithing ok), I get such data (list of Types; for each item expanded:false, isleaf:false, loaded:flase):


{

"page":1,

"total":1,

"records":10000,

"rows":[

{"id":1,"cell":["u041au043eu043cu043fu044cu044eu0442u0435u0440",1,0,"null","false","false","false"]},

{"id":2,"cell":["u041du043eu0443u0442u0431u0443u043a",2,0,"null","false","false","false"]},

{"id":3,"cell":["u041cu043eu043du0438u0442u043eu0440",3,0,"null","false","false","false"]},

… ,

{"id":36,"cell":["u0412u043du0435u0448u043du0438u0439 HDD",36,0,"null","false","false","false"]}

]

}


Ok… I've got the correct list…


Next, I click at any node (for example – id=3) and get the responce from server:


{

"page":1,

"total":1,

"records":10000,

"rows":[

{"id":38,"cell":["Samsung B2230W",38,1,3,"true","true","true"]},

{"id":53,"cell":["u041cu043eu043du0438u0442u043eu0440 LCD",53,1,3,"true","true","true"]},

{"id":54,"cell":["u041cu043eu043du0438u0442u043eu0440 CRT",54,1,3,"true","true","true"]},

{"id":410,"cell":["Philips 40PFL5606H/60",410,1,3,"true","true","true"]}

]

}

Ok… It's loaded correctly. I got subnodes for node 3. For each node expanded – true; isleaf – true; isloaded – true.


Then, I'm trying to collapse node 3, but there is no effect. And when I'm trying to expand any other root-node – I get the error:


Uncaught TypeError: Cannot read property 'isLeaf' of undefined; jquery.jqGrid.src.js:10129

Stack:


Uncaught TypeError: Cannot read property 'isLeaf' of undefined jquery.jqGrid.src.js:10129 

$.jgrid.extend.setTreeNode.each.$.find.css.bind.target jquery.jqGrid.src.js:10129

jQuery.event.dispatch jquery-1.7.1.js:3256

jQuery.event.add.elemData.handle.eventHandle jquery-1.7.1.js:2875


I've broken my brain… =(

Please, help.Cry

15:51
17/05/2012


CrazyXoma

Member

posts 3

I don't khow why, but after the second responce all data replaced with new data from responce…

So, what i have:

1. Load grid:

-Type1

-Type2

-Type3

Data:

-Type1

-Type2

-Type3

2. Expand the node:

Grid:

-Type1

–Model1

–Model2

–Model3

–Model4

-Type2

-Type3

Data:

-Model1

-Model2

-Model3

-Model4


So, by clicking at the any type, it can't load any more item, because it can't find the id of clicked item…


Why it replaced all data with new response and don't add it?

No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

43 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9591

Posts: 28784

Membership:

There are 10170 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1157

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7009 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information