~~~
/**
* 查看
*/
public function index()
{
if ($this->request->isAjax()) {
$where =[];
$request = $this->request->request();
if ( ! empty($request['search'])) {
$where['name'] = ['like' , $request['search'] . '%'];
}
$tree = Tree::instance();
$tree->init(collection($this->model->where($where)->order('weigh desc,id desc')->select())->toArray(), 'pid');
$treeData = $tree->getTreeList($tree->getTreeArray(0), 'name');
// $treeArr = array_column($treeData, 'name', 'id');
$list = [];
foreach ($treeData as $k => $v) {
$list[] = $v;
}
$total = count($list);
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
~~~
~~~
{field: 'name', title: __('Name'), operate: 'LIKE', align: 'left', formatter:function (value, row, index) {
return value.toString().replace(/(&|&)nbsp;/g, ' ');
}
},
~~~