JQueryeasyui combined with ThinkPHP for data display reading

Source: Internet
Author: User
JQueryeasyui is used in combination with ThinkPHP. regarding the problem of reading data display, the original project wrote an EasyUI class, which wrote a datagrig () method.
Public function _ datagrid ($ tag ){
$ Id =! Empty ($ tag ['id'])? $ Tag ['id']: strtolower (CONTROLLER_NAME. '_'. ACTION_NAME. '_ datagrid ');
$ Style =! Empty ($ tag ['style'])? $ Tag ['style']: '';
// Default parameter
$ DataOptions = array (
'Border' => false,
'Fit '=> true,
'Fitcolumns '=> true,
'Rownumbers '=> true,
'Singleselect' => true,
'Pagination' => true,
'Pagelist' => array (20, 30, 50, 80, 100 ),
'Pagesize' => cookie ('pagesize ')? Cookie ('pagesize'): C ('datagrid _ PAGE_SIZE '),
);
$ Options = $ tag ['options']? $ This-> autoBuildVar ($ tag ['options']): 'Array ()';
$ Fields = $ tag ['fields']? $ This-> autoBuildVar ($ tag ['fields']): 'null ';

$ ParseStr ='

\ 'Style = "'. $ style.'"> ';$ ParseStr. =' $ Arr): if (isset ($ arr [\ 'formatter \ ']): unset ($ arr [\ 'formatter \']); endif; echo" "; Endforeach; endif;?> ';$ ParseStr. ='
". $ Key ."
';

Return $ parseStr;
}
This is the logic written in the controller.
$ Datagrid = array (
'Options' => array (
'Title' => $ currentpos,
'URL' => U ('UC/page', array ('grid' => 'datagrid ')),
'Toolbar' => 'UC _ pages_datagrid_toolbar ',
),
'Fields' => array (
'Page' => array ('field' => 'Page', 'width' => 15, 'sortable' => true ),
'Access' => array ('field' => 'private', 'width' => 15, 'sortable' => true ),
'Management operation' => array ('field' => 'id', 'width' => 15, 'formatter '=> 'ucagesoperateformatter '),
)
);


$ This-> assign ('datagrid ', $ datagrid );
The page references tags in this way, and the data comes out.




The problem is that this is the pages table for operations. the values of Field id, page, private, and private are 0 or 1, in the controller, field =, 'private' is used to display 0 or 1 to the page, but our requirement is that when the value of the database privat field is 0, the page shows public and 1, private is displayed on the page. What can be done without changing the table content and structure, that is, not moving the table? Please help me. thank you!


Reply to discussion (solution)

My mind was so hot that I suddenly found that the display of the column with management operations could be realized!
On the pages page, I defined a formatting function ucPagesAccessFormatter ()
// Access format
Function ucPagesAccessFormatter (val ){
Var btn = [];
If (val = 0 ){
Return "public ";
} Else {
Return "private ";
}
}
Write in the controller:
'Fields' => array (
'Page' => array ('field' => 'Page', 'width' => 15, 'sortable' => true ),
'Access' => array ('field' => 'private', 'width' => 15, 'formatter '=> 'ucagesaccessformatter '),
'Management operation' => array ('field' => 'id', 'width' => 15, 'formatter '=> 'ucagesoperateformatter '),
)
The result page is displayed:

Who did you reply? I'll give you a score. I can't give it to myself, or it will be a waste!

Er, easyUI, php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.