//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
$search = $this->request->request("search");
$type = $this->request->request("type");
$offset = $this->request->request("offset");
$limit = $this->request->request("limit");
//构造父类select列表选项数据
$list = [];
$tree = Tree::instance();
$tree->init(collection($this->model->order('id desc')->select())->toArray(), 'pid');
$this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'grade');
$categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
foreach ($this->categorylist as $k => $v) {
$categorydata[$v['id']] = $v;
}
$total = count( $this->categorylist);
$result = array("total" => $total, "rows" => array_slice($this->categorylist,$offset,$limit));
return json($result);
}
return $this->view->fetch();