KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Using (RemoveColumn) will stop the (options) array of DataTables to work #1333

Closed Sarah opened this topic on on Mar 5, 2020 - 5 comments

Sarah commented on Mar 5, 2020

Hello,

I am using the following code and working like a charm:

DataTables::create(array(

    "dataSource"=>$this->dataStore("employees"),
	"options"=>array(
		"fixedHeader"=>true,
		"select"=>true,
		"colReorder"=>true,
		"paging"=>false,
		"searching"=>true,
		"rowGroup"=>array(
		 "startRender"=>  "function ( rows, group ) {
                        return group;
                            }",
                        "endRender"=> "function ( rows, group ) {
                        return group +' ('+rows.count()+')';
                        }",
		    "dataSrc"=> 10,
		    )
    ),

However, whenever i used: ->pipe(new RemoveColumn(array("order")))

The 'options' array will stop working i.e. the (Searching) input field will disappear, the Resorting arrows will disappear, the colreordering feature along with row select feature all will stop working!

What should I do? what is the link between (RemoveColumn) and 'options' array in DataTables?

Sarah commented on Mar 5, 2020

Full code of protected function setup()

{
$this->src('data')
  	->pipe(new RemoveColumn(array("order")))
    ->pipe($this->dataStore("employees"));
} 

and full code of DataTables

DataTables::create(array(

    "dataSource"=>$this->dataStore("employees"),
	"options"=>array(
		"fixedHeader"=>true,
		"select"=>true,
		"colReorder"=>true,
		"paging"=>false,
		"searching"=>true,
		"rowGroup"=>array(
		 "startRender"=>  "function ( rows, group ) {
            return group;
        }",
        "endRender"=> "function ( rows, group ) {
            return group +' ('+rows.count()+')';
        }",
		"dataSrc"=> 10,
		),
		"order"=>array(
            array(11,"asc")
        ),
    ),
    "cssClass"=>array(
        "table"=>"table table-bordered"
    ),

));
KoolReport commented on Mar 5, 2020

I see that you have this line of code:

"order"=>array(
            array(11,"asc")
)

When you remove a column, the number of columns will change as well as the position of columns following the removed column, so it may cause the issue of column not found.

Sarah commented on Mar 5, 2020

Thank you so much, is there a way to use a certain column (in ordering for example or rowGrouping) but not showing it in the dataTable as a column?

David Winterburn commented on Mar 6, 2020

Yes, you can include columns in the DataTables setup without showing them like this:

DataTables::create(array(
    ...
    "options" => array(
            ...
            'columnDefs' => array(
                ...
                [
                    'visible' => false,
                    'targets' => [0, 1], // hide the 1st and 2nd columns
                ],

Hope this helps!

Sarah commented on Mar 6, 2020

Yes perfect thank you

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

DataGrid