Rumah > Artikel > pembangunan bahagian belakang > ThinkPHP+EasyUI的实例讲解
假设数据库中会计科目数据表的字段为:id,code,name,islast。分别为自增主键,科目编码,科目名称,是否为末级("1"表示末级科目)。这里在Thinkphp的模型层中使用递归来构建ComboTree所需的数据,代码及注解如下:
AccountModel = ->field('id,code,name,islast')->( & = (['code'( == 3['pid'] = 0['pid'] = (['code'],0,-2 ->createTree( createSubTree(, = ( =>(['pid'] == = 'id' => ['id'], 'text'=>['name'], 'state'=>(['islast'] != 1)?'closed':'open'(['islast'] != 1 = ->createSubTree(,['code'(!(['children'] = (, createTree( = ( => (['pid'] == 0 = 'id' => ['id'], 'text'=>['name'], 'state'=>'closed' = ->createSubTree(,['code'(!(['children'] = [] =
类似上述的数据(如部门,地区等)需要构建树形菜单的简单修改代码后基本都能实现类似功能。
Atas ialah kandungan terperinci ThinkPHP+EasyUI的实例讲解. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!