From 021d0643d04347143a8434ecde8350d2f38f49ce Mon Sep 17 00:00:00 2001 From: chentao Date: Wed, 14 Jun 2023 15:37:39 +0800 Subject: [PATCH] * Automatically detect and load the field settings of the data table for the current method within the datatable module. --- module/datatable/control.php | 4 +--- module/datatable/model.php | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/module/datatable/control.php b/module/datatable/control.php index 64b730d114..a77f02e2b5 100644 --- a/module/datatable/control.php +++ b/module/datatable/control.php @@ -139,9 +139,7 @@ class datatable extends control if(isset($this->config->datatable->$target->cols)) $setting = $this->config->datatable->$target->cols; if(empty($setting)) { - $cfgMethod = ($module == 'program' && $method == 'productview') ? $method : ''; - - $cols = $this->datatable->getFieldList($module, $cfgMethod); + $cols = $this->datatable->getFieldList($module, $method); $cols = $this->datatable->formatFields($module, $cols, false); } else diff --git a/module/datatable/model.php b/module/datatable/model.php index a946bc73a0..c5f5a637e5 100644 --- a/module/datatable/model.php +++ b/module/datatable/model.php @@ -27,7 +27,7 @@ class datatableModel extends model if(!isset($this->config->$module)) $this->loadModel($module); $config = $this->config->$module; - if(!empty($method)) $config = $config->$method; + if(isset($config->$method) && isset($config->$method->dtable)) $config = $config->$method; $fieldList = $config->dtable->fieldList; /* If doesn't need product, remove 'product' field. */ @@ -90,13 +90,12 @@ class datatableModel extends model { $method = $this->app->getMethodName(); $datatableId = $module . ucfirst($method); - $cfgMethod = ($module == 'program' && $method == 'productview') ? $method : ''; $module = zget($this->config->datatable->moduleAlias, "$module-$method", $module); if(!isset($this->config->$module)) $this->loadModel($module); if(isset($this->config->datatable->$datatableId->cols)) $setting = json_decode($this->config->datatable->$datatableId->cols, true); - $fieldList = $this->getFieldList($module, $cfgMethod); + $fieldList = $this->getFieldList($module, $method); if(empty($setting)) { $setting = $this->formatFields($module, $fieldList);