我遇到了折叠数据的问题,但是正确地扩展了工作。控制台很清晰,图标箭头(显示打开或关闭)正在工作(也正常更改)。在什么原因可能是一个问题?
我的所作所为:在第一次加载时,我加载了根数据和所有引用他的数据。点击后我加载所有引用点击元素的内容。
$(document).ready(function () {
$('#tree').jqGrid({
'url': '/user/tree',
'colNames': ['id', 'ФИО', "Телефон", "E-mail", "Профиль"],
'colModel': [
{name: 'id', index: 'id', key: true, hidden: true},
{name: 'name', index: 'name', width: 280},
{name: 'phone', index: 'phone', width: 130, align: 'right'},
{name: 'email', index: 'email', width: 220, align: 'right'},
{name: 'link', index: 'link', align: 'center'}
],
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'name',
datatype: "json",
height: 'auto',
pager: "#pager"
})
});
我得到的数据:
{
"rows":[
{
"id":10,
"cell":{
"name":"ajlshdjk hdjksdhakjdh",
"phone":"878971",
"email":"test@gmail.com7",
"parent":9,
"link":"test",
"level":3,
"isLeaf":false,
"expanded":false,
"id":10
}
},
{
"id":11,
"cell":{
"name":"akjhsdkjgh kdgadkhsgdhkqh",
"phone":"98712873891",
"email":"test@gmail.com8",
"parent":9,
"link":"test",
"level":3,
"isLeaf":false,
"expanded":false,
"id":11
}
}
],
"records":2,
"total":1,
"page":1
}
服务器端看起来像这样:
$level = ++$data['level'];
$nodeid = $data['nodeid'];
$user = User::find($nodeid);
$refs = HelperService::getNextLevelMyRefs($user);
$rows = array();
foreach ($refs as $item) {
$obj = new \stdClass();
$obj->id = $item->id;
$obj->cell = array(
'name' => $item->firstname . ' ' . $item->lastname,
'phone' => $item->phone,
'email' => $item->email,
'parent' => $item->referer_id,
'link' => 'test',
'level' => $level,
'isLeaf' => $this->checkForRefs($item), //need check
'expanded' => false,
'id' => $item->id
);
array_push($rows, $obj);
}
以下是服务器的根响应:
{
"rows": [
{
"id": 7,
"cell": {
"name": "sjldhflj sdjfhsjh",
"phone": "1283918",
"email": "test@gmail.com4",
"parent": null,
"link": "test",
"level": 0,
"isLeaf": false,
"expanded": true,
"id": 7
}
},
{
"id": 8,
"cell": {
"name": "jsdhfjlash jlhsxjdhjk",
"phone": "878",
"email": "test@gmail.com5",
"parent": 7,
"link": "test",
"level": 1,
"isLeaf": false,
"expanded": false,
"id": 8
}
}
],
"records": 2,
"total": 1,
"page": 1
}
抱歉这个问题无能为力,这是我第一次使用这个库。