From ec6fc471ebbbc8c6735f027ae62ebba7eecd665b Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 30 Nov 2023 14:03:55 +0800 Subject: [PATCH] * zin: update dtable wg. --- lib/zin/wg/dtable/v1.php | 42 ++-------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/lib/zin/wg/dtable/v1.php b/lib/zin/wg/dtable/v1.php index c6a2f3e03c..1750f14c94 100644 --- a/lib/zin/wg/dtable/v1.php +++ b/lib/zin/wg/dtable/v1.php @@ -17,7 +17,8 @@ class dtable extends wg 'createAttr?:string', // 表格数据源为空时的创建链接属性。 'sortLink?:array|string', // 排序链接。 'orderBy?:string', // 排序字段。 - 'loadPartial?: bool' // 启用部分加载,不更新浏览器地址栏 URL。 + 'loadPartial?: bool', // 启用部分加载,不更新浏览器地址栏 URL。 + 'loadOptions?: array' // 分页和排序加载选项。 ); static $dtableID = 0; @@ -40,7 +41,6 @@ class dtable extends wg $this->initCustomCols(); $this->initCols($module); $this->initSortLink(); - $this->initPager(); $this->initFooterBar(); $tableData = $this->prop('data', array()); @@ -62,44 +62,6 @@ class dtable extends wg list($orderByName, $orderByType) = explode('_', strpos($orderBy, '_') === false ? $orderBy . '_desc' : $orderBy); $this->setProp('orderBy', array($orderByName => $orderByType)); } - - $sortLink = $this->prop('sortLink'); - if(is_string($sortLink) && !str_contains($sortLink, 'RAWJS')) $this->setProp('sortLink', array('url' => $sortLink, 'data-app' => 'current', 'data-load' => 'table', 'data-selector' => 'dtable', 'data-partial' => $this->prop('loadPartial'))); - } - - /** - * 格式化表格分页属性。 - * Format table pagination properties. - * - * @access public - * @return void - */ - public function initPager() - { - $pager = $this->prop('footPager'); - if(!empty($pager) && isset($pager['items'])) - { - $loadOptions = array(); - $loadOptions['data-load'] = 'table'; - $loadOptions['data-target'] = $this->prop('id'); - $loadOptions['data-selector'] = 'dtable'; - if($this->prop('loadPartial')) $loadOptions['data-partial'] = $this->prop('loadPartial'); - - if(!isset($pager['btnProps'])) $pager['btnProps'] = array_merge(array('type' => 'ghost', 'size' => 'sm'), $loadOptions); - foreach($pager['items'] as $index => $item) - { - if($item['type'] != 'size-menu') continue; - if(isset($item['itemProps'])) - { - $pager['items'][$index]['itemProps'] = array_merge($pager['items'][$index]['itemProps'], $loadOptions); - } - else - { - $pager['items'][$index]['itemProps'] = $loadOptions; - } - } - $this->setProp('footPager', $pager); - } } /**