When I use Koolreport 5.9.1 DataTable Seever Side, the Order function is not working Below is my code
<?php
use \koolreport\datagrid\DataTables;
use \koolreport\widgets\koolphp\Table;
use \koolreport\processes\CalculatedColumn;
use \koolreport\inputs\Select;
if(!isset($_SESSION)){
session_start();
}
$excluded_columns = array();
if ($_SESSION['UserType'] != 'admin') {
$excluded_columns= [ array( "targets" => 5 , "visible" => false), array( "targets" => 6 , "visible" => false)];
}
?>
<div>
<h2 class="text-center m-3">Snags List</h2>
<div class="row m-2">
<div class="col-md-10">
<form id="selectionform" name="selectionform" action='' class="col-md-9 p-0" method="post">
<div class="row">
<div class="col-sm-6">
<label class="form-label">Resopurce</label>
<?php
Select::create(array(
"name"=>"selectResourceId",
"dataStore"=>$this->dataStore("resourceList"),
"defaultOption"=>array("All Resources" => 0 ),
"dataBind"=>array(
"text"=>"ResourceName",
"value"=>"ResourceId",
),
"clientEvents"=>array(
"change"=>"function(){
// console.log( assignedDevice )
frm = document.getElementById('selectionform') ;
frm.action = 'index.php?action=snags&rid='+ selectResourceId.val()+'&statusid='+ selectStatus.val() ;
$('#selectionform').submit();
}",
),
"attributes"=>array(
"class" => "form-select",
)
));
?>
</div>
<div class="col-sm-3">
<label class="form-label">Snag Status</label>
<?php
Select::create(array(
"name"=>"selectStatus",
"dataStore"=>$this->dataStore("SnagStatusList"),
"defaultOption"=>array("Opend Snags" => 0 ),
"dataBind"=>array(
"text"=>"Status",
"value"=>"Id",
),
"clientEvents"=>array(
"change"=>"function(){
// console.log( assignedDevice )
console.log( 'Changed' )
frm = document.getElementById('selectionform') ;
frm.action = 'index.php?action=snags&rid='+ selectResourceId.val()+'&statusid='+ selectStatus.val() ;
$('#selectionform').submit();
}",
),
"attributes"=>array(
"class" => "form-select",
)
));
?>
</div>
</div>
</form>
</div>
<div class="col-md-2 text-end pe-4">
<button type="button" class= "addsnagbtn btn-primary bi bi-gear-wide-connected m-1" data-bs-toggle="tooltip" title="Create Snag"> Add Snag</button>
</div>
</div>
<?php
DataTables::create(array(
"name" => "snagsTable",
'dataSource' => function() {
return $this->src('sqlserver')
->query($this->params['qry'])
->pipe(new CalculatedColumn(array(
"OpenDate"=>array(
"exp"=>function($data){
return formateDate ($data['OpenDate']);
}
)
)))
->pipe(new CalculatedColumn(array(
"WeeksOpen"=>array(
"exp"=>function($data){
return round ( (strtotime(gmdate('Y-m-d H:i:s', time())) - strtotime($data['OpenDate']))/(60*60)/24/7,1);
}
)
)))
->pipe(new CalculatedColumn(array(
"ResponsibilityName"=>array(
"exp"=>function($data){
return getUserNameById($data['ResponsibilityName']);
}
)
)))
->pipe(new CalculatedColumn(array(
"MaintCategoryId"=>array(
"exp"=>function($data){
return getMaintCategoryById($data['MaintCategoryId']);
}
)
)))
->pipe(new CalculatedColumn(array(
"EngineTypeId"=>array(
"exp"=>function($data){
if ( $data['EngineTypeId'] == 0 && $data['SessionId']) {
$sessionData = getEngineTypeBySessionId ($data['SessionId']);
return $sessionData ;
} else {
return getEngineTypeById($data['EngineTypeId']);
}
}
)
)))
->pipe(new CalculatedColumn(array(
"editicon"=>array(
"exp"=>function($data){
return '<div snagid='. $data['Id'] . ' class="editsang btn text-primary p-0" data-bs-toggle="tooltip" title="Edit Snag">
<i class="bi bi-pencil-square"></i>
</div>';
}
)
)));
},
"themeBase" => "bs3",
"serverSide" => true,
"method"=>"get",
"plugins" => ["Buttons"],
"responsive" => true,
"options"=>array(
"dom" => 'Bfrtip',
"buttons" => [ array("extend" => "excel", "className" => "excelButton", "text" => "Export to Excel"),
array("extend" => "pageLength", "className" => "pageButton")
],
"fastRender" => true,
"searching" => true,
"ordering" => true,
"searchOnEnter" => true,
"paging" => true,
"mark" => true,
"order" => array( array(4,"desc") ),
"lengthMenu" => [[15, 30, 50, 100, -1], [15, 30, 50, 100, "All"]],
"columnDefs" => $excluded_columns,
),
"columns"=>array(
"ResourceName"=>array(
"label" => "Resource",
),
"SnagRef"=>array(
"label" => "Ref #",
),
"ManufacturerRef"=>array(
"label" => "Manu. Ref #",
),
"Class"=>array(
"label" => "Priority",
"className" => "text-center"
),
"OpenDate"=>array(
"label" => "Open Date",
"className" => "text-center"
),
"WeeksOpen"=>array(
"label" => "Weeks Open",
"className" => "text-center"
),
"Problem"=>array(
"label" => "Problem",
),
"Status"=>array(
"label" => "Status",
"className" => "text-center",
),
"RasiedBy"=>array(
"label" => "Rasied By",
"className" => "text-center",
),
"ResponsibilityName"=>array(
"label" => "Responsibility",
"className" => "text-center",
),
"MaintCategoryId"=>array(
"label" => "Category",
"className" => "text-center",
),
"EngineTypeId"=>array(
"label" => "Engine",
"className" => "text-center",
),
"editicon"=>array(
"label" => "",
"className" => "text-center",
"searchable" => false,
"orderable" => false,
),
),
"cssClass"=>array(
"table" => "table table-bordered table-striped align-middle small",
"th" => "cssHeader"
)
));
?>