* Automatically detect and load the field settings of the data table for the current method within the datatable module.

This commit is contained in:
chentao
2023-06-14 15:37:39 +08:00
parent fc8dac6898
commit 021d0643d0
2 changed files with 3 additions and 6 deletions
+1 -3
View File
@@ -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
+2 -3
View File
@@ -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);