nur-sery/nur_src/v/bs3/vc/CDatatable.php

57 lines
1.5 KiB
PHP
Raw Normal View History

2023-12-03 22:10:18 +04:00
<?php
namespace nur\v\bs3\vc;
2024-05-21 04:42:55 +04:00
use nur\A;
2023-12-03 22:10:18 +04:00
use nur\b\params\Tparametrable;
2024-05-21 04:42:55 +04:00
use nur\data\types\Metadata;
2023-12-03 22:10:18 +04:00
use nur\v\js;
class CDatatable extends CTable {
use Tparametrable;
2024-05-21 04:42:55 +04:00
const CSS = [
"nur-v-bs3/datatables/datatables.css",
"nur-v-bs3/datatables.css",
];
2023-12-03 22:10:18 +04:00
const JS = "nur-v-bs3/datatables/datatables.js";
const PARAMETRABLE_PARAMS_SCHEMA = [
"dtclass" => ["string", "datatable", "classe des tables mises en forme par Datatable"],
"dtconfig" => ["?array", ["order" => []], "configuration de l'objet"],
2024-05-21 04:42:55 +04:00
"dtauto" => ["?bool", "configurer la table pour que sa taille soit automatique"],
2023-12-03 22:10:18 +04:00
];
protected $ppDtclass;
protected $ppDtconfig;
2024-05-21 04:42:55 +04:00
protected $ppDtauto;
protected function afterSetParametrableParams(array $modifiedKeys, ?Metadata $md=null): void {
parent::afterSetParametrableParams($modifiedKeys, $md);
if (self::was_parametrable_param_modified($modifiedKeys, "dtauto")) {
A::merge($this->ppDtconfig, [
"dom" => "<'row'<'col-sm-12 dt-autodiv'lfi>><'row'<'col-sm-12'tr>><'row'<'col-sm-12 dt-autodiv'p>>",
"bAutoWidth" => false,
]);
A::append($this->ppTableClass, "table-auto");
}
}
2023-12-03 22:10:18 +04:00
protected function getTableClass(): array {
return [$this->ppTableClass, $this->ppDtclass];
}
const HAVE_JQUERY = true;
function printJquery(): void {
?>
<script type="text/javascript">
jQuery.noConflict()(function($) {
$(<?=js::qclass($this->ppDtclass)?>).DataTable(<?=js::qo($this->ppDtconfig)?>);
});
</script>
<?php
}
}