Laravel-datatables: How to create a hidden column?

Created on 29 Mar 2017  路  6Comments  路  Source: yajra/laravel-datatables

As per title: How can one create a hidden column to store data that should not be shown directly?

question

Most helpful comment

Thanks for the answers guys! I think this is resolved. 馃憤

All 6 comments

@thomasmoors the visible property when defining columns.


  private function getColumns()
    {
        return [
            'store_id' => ['name' => 'store_id', 'data' => 'store_id', 'visible' => false],
        ];
    }

Unless ypu want to show that column later, itd be better to just put it as a row attribute using datatable defcolumns

I can give you an example when i get on my computer.

EDIT: I misread the question, this is for rows, not columns.

Woof, I meant createdrow not columndefs

so inside you JS datatable() definition you put something like

createdRow: function( row, data, dataIndex ) {
     $(row).attr({
         "first-attribute": data["firstValue"],
         "second-attribute": data["secondValue"],
     });
 },

and so on
Obviously the attributes and values I wrote are placeholders.
you can find more info here
And don't forget that the datatable documnetation applies to this plugin

And then you just casually $([rowSelector]).attr('first-attribute); when you need what's inside

Thanks for the answers guys! I think this is resolved. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MahdiPishguy picture MahdiPishguy  路  17Comments

Arkhas picture Arkhas  路  15Comments

ezani92 picture ezani92  路  33Comments

jay-shah-rushiinfotech picture jay-shah-rushiinfotech  路  19Comments

fanjavaid picture fanjavaid  路  32Comments