mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°3914 - Polishing: Lists - fix display of datatable and rename attribute for init data
This commit is contained in:
@@ -44,7 +44,10 @@ class DataTable extends UIContentBlock
|
||||
protected $aAjaxData;
|
||||
protected $aDisplayColumns;
|
||||
protected $aResultColumns;
|
||||
protected $sJsonData;
|
||||
/*
|
||||
* array of data to display the first page
|
||||
*/
|
||||
protected $aInitDisplayData;
|
||||
|
||||
/**
|
||||
* Panel constructor.
|
||||
@@ -101,6 +104,7 @@ class DataTable extends UIContentBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $aAjaxData as a JSON
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetJsonAjaxData(): string
|
||||
@@ -179,11 +183,21 @@ class DataTable extends UIContentBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $aInitDisplayData as a JSON This is data of first page
|
||||
* @return string
|
||||
*/
|
||||
public function GetJsonData(): string
|
||||
public function GetJsonInitDisplayData(): string
|
||||
{
|
||||
return $this->sJsonData;
|
||||
return json_encode($this->aInitDisplayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $aInitDisplayData
|
||||
* @return array
|
||||
*/
|
||||
public function GetInitDisplayData(): array
|
||||
{
|
||||
return $this->aInitDisplayData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,9 +205,9 @@ class DataTable extends UIContentBlock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetJsonData(string $sJSON)
|
||||
public function SetInitDisplayData(array $aData)
|
||||
{
|
||||
$this->sJsonData = $sJSON;
|
||||
$this->aInitDisplayData = $aData;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,11 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
}
|
||||
|
||||
if (!isset($aExtraParams['surround_with_panel']) || $aExtraParams['surround_with_panel']) {
|
||||
$iCount = $oSet->Count();
|
||||
if(!empty($oDataTable->GetInitDisplayData()) && isset($oDataTable->GetInitDisplayData()['recordsTotal'])){
|
||||
$iCount = $oDataTable->GetInitDisplayData()['recordsTotal'];
|
||||
} else {
|
||||
$iCount = $oSet->Count();
|
||||
}
|
||||
$sTitle = (isset($aExtraParams['panel_title'])) ? $aExtraParams['panel_title'] : "";
|
||||
$oContainer = PanelUIBlockFactory::MakeForClass($oSet->GetClass(), $sTitle)->AddCSSClass('ibo-datatable-panel');
|
||||
$oContainer->SetSubTitle(Dict::Format("UI:Pagination:HeaderNoSelection", $iCount));
|
||||
@@ -438,7 +442,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
]);
|
||||
$oDataTable->SetDisplayColumns($aColumnDefinition);
|
||||
$oDataTable->SetResultColumns($oCustomSettings->aColumns);
|
||||
$oDataTable->SetJsonData(json_encode(AjaxRenderController::GetDataForTable($oSet, $aClassAliases, $aColumnsToLoad, $sIdName, $aExtraParams)));
|
||||
$oDataTable->SetInitDisplayData(AjaxRenderController::GetDataForTable($oSet, $aClassAliases, $aColumnsToLoad, $sIdName, $aExtraParams));
|
||||
|
||||
return $oDataTable;
|
||||
}
|
||||
@@ -670,7 +674,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
]);
|
||||
$oDataTable->SetDisplayColumns($aColumnDefinition);
|
||||
$oDataTable->SetResultColumns($oCustomSettings->aColumns);
|
||||
$oDataTable->SetJsonData(json_encode(AjaxRenderController::GetDataForTable($oSet, $aClassAliases, $aColumnsToLoad, $sIdName, $aExtraParams)));
|
||||
$oDataTable->SetInitDisplayData(AjaxRenderController::GetDataForTable($oSet, $aClassAliases, $aColumnsToLoad, $sIdName, $aExtraParams));
|
||||
|
||||
return $oDataTable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user