How To Control Column Header

How To Control Column Header

bola2apibola2api Posts: 4Questions: 2Answers: 0
edited November 2023 in Free community support

Hi all,
I have a question, how can I control the column header properties based on let say someone role. I have an .aspx where the table header are controlled by the server side. if the user is admin the page will render extra column 'Action'

                        <table class="table table-sm table-bordered table-hover" id="table">
                            <thead class="bg-primary">
                                <tr class="text-white">
                                    <th>No.</th>
                                    <th>Ticket #</th>
                                    <th>Name</th>
                                    <th>Destination</th>
                                    <th>Remarks</th>
                                    <th>Status</th>
                                    <th>Action</th> //rendered from server-side if the user is Admin
                                </tr>
                            </thead>
                        </table>

                            var table = $(`#table`).DataTable({
                                stateSave: true,
                                ajax: {
                                    url: `page.aspx/function`,
                                    type: "POST",
                                },
                                columns: [
                                    { "data": 'name' },
                                    { "data": 'destination' },
                                    { "data": 'remarks' },
                                    { "data": action}, <---- this is the column i want to control based on role
                                ],
                                processing: true,
                                serverSide: true,
                            });
Sign In or Register to comment.