Example explanation of ThinkPHP+EasyUI

零下一度
Release: 2023-03-10 17:10:01
Original
3475 people have browsed it

Assume that the fields of the accounting data table in the database are: id, code, name, islast. They are the auto-increment primary key, account code, account name, and whether it is the last-level account ("1" indicates the last-level account). Here, recursion is used in the model layer of Thinkphp to build the data required by ComboTree. The code and annotations are as follows:

 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'] = [] =
Copy after login

Data similar to the above (such as departments, regions, etc.) need to build a tree shape Similar functions can basically be achieved by simply modifying the menu code.

The above is the detailed content of Example explanation of ThinkPHP+EasyUI. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template