From 00a47077f127c3a417a1cdefbee2ca243bc5d538 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 6 Jul 2023 19:13:10 +0800 Subject: [PATCH] * Change the table data. --- framework/helper.class.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/framework/helper.class.php b/framework/helper.class.php index 5a4aad03ca..888dd13050 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -509,6 +509,7 @@ function initPageEntity(object $object): array */ function initTableData(array $items, array &$fieldList, object $model = null): array { + $items = setParent($items); if(empty($fieldList['actions'])) return $items; foreach($fieldList['actions']['menu'] as $actionMenu) @@ -595,6 +596,24 @@ function initTableData(array $items, array &$fieldList, object $model = null): a } } + if(count($item->actions) > $maxActionCount) $maxActionCount = count($item->actions); + } + if(isset($fieldList['actions'])) $fieldList['actions']['minWidth'] = $maxActionCount * 24 + 24; + + return array_values($items); +} + +/** + * Set the parent property of the data. + * + * @param array $items + * @access public + * @return array + */ +function setParent(array $items) +{ + foreach($items as $item) + { /* Set parent attribute. */ $item->isParent = false; if(isset($item->parent) && $item->parent == -1) @@ -606,12 +625,8 @@ function initTableData(array $items, array &$fieldList, object $model = null): a if(!empty($item->parent) && !isset($items[$item->parent])) $item->parent = ''; if(!empty($item->parent) && isset($items[$item->parent])) $items[$item->parent]->isParent = true; - - if(count($item->actions) > $maxActionCount) $maxActionCount = count($item->actions); } - if(isset($fieldList['actions'])) $fieldList['actions']['minWidth'] = $maxActionCount * 24 + 24; - - return array_values($items); + return $items; } /**