MDL-67915 core_table: add support for hide and show of columns

This commit is contained in:
Simey Lameze
2020-04-24 18:23:34 +08:00
parent 9df4a4de18
commit e2f12c2220
12 changed files with 131 additions and 31 deletions
+16 -1
View File
@@ -115,6 +115,14 @@ class fetch extends external_api {
VALUE_REQUIRED,
null
),
'hiddencolumns' => new external_multiple_structure(
new external_value(
PARAM_ALPHANUMEXT,
'Name of column',
VALUE_REQUIRED,
null
)
),
]);
}
@@ -146,7 +154,8 @@ class fetch extends external_api {
?string $firstinitial = null,
?string $lastinitial = null,
?int $pagenumber = null,
?int $pagesize = null
?int $pagesize = null,
?array $hiddencolumns = null
) {
global $PAGE;
@@ -163,6 +172,7 @@ class fetch extends external_api {
'lastinitial' => $lastinitial,
'pagenumber' => $pagenumber,
'pagesize' => $pagesize,
'hiddencolumns' => $hiddencolumns,
] = self::validate_parameters(self::execute_parameters(), [
'component' => $component,
'handler' => $handler,
@@ -175,6 +185,7 @@ class fetch extends external_api {
'lastinitial' => $lastinitial,
'pagenumber' => $pagenumber,
'pagesize' => $pagesize,
'hiddencolumns' => $hiddencolumns,
]);
$tableclass = "\\{$component}\\table\\{$handler}";
@@ -221,6 +232,10 @@ class fetch extends external_api {
$pagesize = 20;
}
if ($hiddencolumns !== null) {
$instance->set_hidden_columns($hiddencolumns);
}
$context = $instance->get_context();
self::validate_context($context);
$PAGE->set_url($instance->get_base_url());