Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2366

Show column if you have the rights

$
0
0

Is it possible to show some more column if you have the rights for that?
I have written the rights in the $_SESSION. How can I read the $_SESSION rights with js. I do it with following line on the of my php script.

            $rdata = array(
                "data" => $data,
                "draw" => "1",
                "recordsTotal" => $nr_datarows,
                "recordsFiltered" => $nr_datarows,
                "recordRights" => (isset($_SESSION["administrator"]) and $_SESSION["administrator"] == "1") ? "1" : "0"
            );
            echo json_encode($rdata);

I know that js can not read the $_SESSION, but maybe you have better idea. Now comes my Problem. How can I show the columns if the rights are ok.
I tried something like this and more, but it did not work.

        "columnDefs": [
            { targets: [ 0, 1, 2, 3, 4, 5, 6, 7, 9 ], visible: true },
            { render: function(data, type, row){
                    ($data.recordRights == '1') ? (targets: 8, visible: true) : (targets: 8, visible: true);
            }},
            { targets: '_all', visible: false }
        ],

I know that code is bullshit, but I have no more ideas, how can I do this.
Can you give me an hint, what I should do?

Andreas


Viewing all articles
Browse latest Browse all 2366

Trending Articles