The table output component jumps to [1] [full screen preview]
$ Data ['datas'], 'columns '=> [['type' => 'checkbox', 'name' => 'uid ', 'id' => 'user', 'htmloptions '=> ['style' => 'color: Green',], ['name' => 'visitid ', 'header' => 'follow-up ID', 'value' => '$ data ["visitid"]'], ['name' => 'visitname ', 'header' => 'scheme name', 'value' => '$ data ["visitname"]'], ['name' => 'joiner _ nums ', 'header' => 'Participant ', 'value' => 'visitdbmodel: getJoiner_nums ($ data)'], ['name' =>'re Alname', 'header' => 'creator ', 'value' =>' $ data ["realname"] '], ['name' => 'Department _ name ', 'header' => 'Department ', 'value' =>' $ data ["department_name"] '], ['name' => 'ques _ nums ', 'header' => 'case', 'value' => '$ data ["ques_nums"]'], ['type' => 'click ', 'header' => 'operation', 'template' => '{invitation} {detail }', operation template configuration 'htmlopexception' => ['class' => 'doit'], 'buttons' => ['invitation' => ['label' => 'invite participants Person ', 'URL' =>'/admin/visit/invitation /? Visitid = $ data ["visitid"] ', 'htmlopexception' => ['class' => 'fllow _ add_btn'], 'visable' => 'isset ($ _ GET ["type"]) & $ _ GET ["type"] = "myvisit "? True: false',], 'detail' => ['label' => 'detail', 'URL' => '/admin/visit/detail /? Visitid = $ data ["visitid"] ', 'htmloptions' => ['class' => 'fllow _ add_btn '], 'visitied' => 'visitdbmodel :: test ($ data) ', permission control expression. if the result is true, the button is displayed; otherwise, it is not displayed],]);?> * Use with multiple selection boxes and Operation columns *
$ Data ['datas'], 'columns '=> [['type' => 'checkbox', 'name' => 'uid ', 'id' => 'uid', 'htmloptions '=> ['style' => 'color: Green',], ['name' => 'visitid ', 'header' => 'follow-up ID', 'value' => '$ data ["visitid"]'], ['name' => 'visitname ', 'header' => 'scheme name', 'value' => '$ data ["visitname"]'], ['name' => 'joiner _ nums ', 'header' => 'Participant ', 'value' => 'visitdbmodel: getJoiner_nums ($ data)'], ['name' => 'rea Lname', 'header' => 'creator ', 'value' =>' $ data ["realname"] '], ['name' => 'Department _ name ', 'header' => 'Department ', 'value' =>' $ data ["department_name"] '], ['name' => 'ques _ nums ', 'header' => 'case', 'value' => '$ data ["ques_nums"]'], ['type' => 'click ', 'header' => 'operation', 'template' => '{invitation} {detail }', 'buttons' => ['invitation' => ['label' => 'invite participants ', 'URL' =>'/admin/visit/invitation /? Doctor_id = $ data ["doctor_id"] ', 'htmloptions' => ['class' => 'fllow _ add_btn '], 'visable' => 'true',], 'detail' => ['label' => 'detail', 'URL' => '/admin/visit/detail /? Visitid = $ data ["visitid"] ', 'htmlopexception' => ['class' => 'fllow _ add_btn'], 'visible '=> 'false',],]);?> ** @ Author: the place where the wind resides */class ListView {/*** receives data, which will process data * @ var type */public $ datas; /*** table html options * @ var type */public $ htmlOptions;/*** data field * @ var type */public $ columns; /*** messages with empty data displayed * @ var type */public $ emptyMessage = 'no date'; public function _ construct ($ datas) {foreach ($ datas as $ k => $ v) $ this-> $ k = $ v; $ this-> initData ();} public function run () {$ html = ''; $ html. = html :: Tag ('table', $ this-> htmlOptions, false); ob_start (); ob_implicit_flush (false); $ this-> renderStart (); $ this-> renderContent (); $ html. = ob_get_clean (); $ html. = html: endTag ('table'); return $ html;}/*** rendering header */protected function renderStart () {$ html = ''; $ html. = html: tag ('thead'); $ html. = html: tag ('tr '); $ html. = $ this-> _ renderStart ('th'); $ html. = html: endTag ('tr'); $ html. = html: endTag ('Thead'); echo $ html;} protected function _ renderStart ($ tag) {if (empty ($ this-> columns) return ''; $ html = ''; foreach ($ this-> columns as $ data) {if (isset ($ data ['type']) & $ data ['type'] = 'checkbox') {if (isset ($ data ['htmlopexception'] ['type']) unset ($ data ['htmlopexception'] ['type']); if (isset ($ data ['htmlopexception'] ['name']) unset ($ data ['htmlopexception'] ['name']); if (isset ($ data ['htmlopexception'] ['id' ]) Unset ($ data ['htmlopexception'] ['id']); if (isset ($ data ['htmlopexception'] ['value']) unset ($ data ['htmlopexception'] ['value']); $ data ['htmlopexception'] ['type'] = $ data ['type']; $ data ['htmlopexception'] ['name'] = $ data ['name']. '[]'; $ data ['htmloptions '] ['id'] = $ data ['id']; $ data ['htmlopexception'] ['value'] = ''; $ data ['htmlopexception'] ['onclick'] = 'selectall () '; $ checkbox = html:: tag ('input', $ data ['htmlopexception']); $ ht Ml. = html: tag ($ tag, [], $ checkbox); $ html. = $ this-> regsterJs ($ data ['id'], $ data ['name']. '[]');} else {if (isset ($ data ['raw']) & $ data ['raw'] = 'false ') {eval ('$ header = '. $ data ['header']. ';'); if (isset ($ header) {$ data ['header'] = $ header;} $ html. = html: tag ($ tag, [], isset ($ data ['header'])? $ Data ['header']: '') ;}return $ html;}/*** rendered content */protected function renderContent () {$ html = ''; $ html. = html: tag ('tbody'); $ html. = $ this-> _ renderContent ('TD '); $ html. = html: endTag ('tbody'); echo $ html;}/*** initialize original data */protected function initData () {if (empty ($ this-> datas) return; foreach ($ this-> datas as $ I =>& $ data) {foreach ($ this-> columns as $ value) {if (isset ($ value ['typ E ']) & $ value ['type'] = 'checkbox') {$ data ['checkbox'] = $ this-> _ checkData ($ value, $ data);} if (isset ($ value ['type']) & isset ($ value ['header']) & isset ($ value ['template']) & isset ($ value ['buttons']) $ data ['actions'] = $ this-> _ initData ($ value, $ data) ;}} protected function _ checkData ($ value, & $ data) {if (! Isset ($ value ['htmlopexception']) $ value ['htmlopexception'] = []; $ value ['htmlopexception'] ['type'] = 'checkbox '; $ value ['htmlopexception'] ['name'] = $ value ['name']. '[]'; $ value ['htmloptions '] ['value'] = ''; return html: tag ('input ', $ value ['htmlopexception']);} /*** specific initialization execution ** @ param type $ value * @ param array $ data * @ return array */protected function _ initData ($ value, & $ data) {$ data ['actions'] = []; foreach ($ va Lue ['buttons'] as $ key => $ v) {if (isset ($ v ['visable']) {eval ('$ visible = '. $ v ['visible ']. ';'); if (! $ Visible) {$ value ['template'] = str_replace ("{$ key}", '', $ value ['template']); unset ($ value ['buttons'] [$ key]); continue ;}} eval ('$ url = "'. str_replace ('"','', $ v ['URL']). '";'); $ v ['htmlopexception'] ['href '] = $ url; $ data ['actions'] [$ key] = html :: tag ('A', $ v ['htmlopexception'], $ v ['label']);} foreach ($ data ['actions'] as $ k => $ v) {$ value ['template'] = str_replace ("{{$ k}", $ v, $ value ['template']);} Return $ value ['template'];}/*** render the specific content * @ param type $ tag * @ return string */public function _ renderContent ($ tag) {$ html = ''; if (empty ($ this-> datas) {$ html. = html: tag ('tr '); $ html. = html: tag ($ tag, ['colspan '=> count ($ this-> columns)], $ this-> emptyMessage); $ html. = html: endTag ('tr'); return $ html;} foreach ($ this-> datas as $ data) {$ html. = html: tag ('tr'); foreach ($ this-> columns S $ value) {if (! Isset ($ value ['htmlopexception']) $ value ['htmlopexception'] = []; if (isset ($ value ['type']) {if ($ value ['type'] = 'checkbox' | $ value ['type'] = 'click ') {if ($ value ['type'] = 'checkbox') {if (isset ($ value ['htmlopexception'] ['type']) unset ($ value ['htmlopexception'] ['type']); if (isset ($ value ['htmlopexception'] ['name']) unset ($ value ['htmlopexception'] ['name']); $ value ['htmlopexception'] ['type'] = $ value ['type']; $ val Ue ['htmlopexception'] ['name'] = $ value ['name']. '[]'; $ value ['htmlopexception'] ['value'] = $ data [$ value ['name']; $ checkbox = html :: tag ('input', $ value ['htmlopexception']); $ html. = html: tag ($ tag, [], $ checkbox);} else {$ html. = html: tag ($ tag, $ value ['htmlopexception'],! Isset ($ data ['actions'])? False: $ data ['actions']) ;}} else {eval ('$ v = '. $ value ['value']. ';'); $ html. = html: tag ($ tag, $ value ['htmlopexception'], $ v) ;}}$ html. = html: endTag ('tr');} return $ html;}/*** register js code * @ param type $ id */protected function regsterJs ($ id, $ name) {$ js = <