jeudi 13 février 2020

How to display a text on a column data according to condition in jQuery DataTable?

The column is_active has 2 types of value, value 1 should be equal to Active and value 2 should be equal to Inactive. Now I want to display Active or Inactive in the column according to a condition. How to do this?

Table implementation

function loadTemplates() {
        template_table = $('#template-table').DataTable({
            processing: true,
            serverSide: true,
            "ajax": {
                "url": 'template-table',
                "type": "POST",
                "data": function (d) {
                    d._token = "";
                }
            },
            "aaSorting": [[0, 'desc']],
            "fnDrawCallback": function (oSettings) {
                rowHighlight('template-table');
                selectRowOnTableLoad(oSettings, 'id', selectedRowID);
                dataTableRow = oSettings;
            },
            columns: [
                {data: 'id'},
                {data: 'title'},
                {data: 'start_date'},
                {data: 'end_date'},
                {data: 'is_active'},//column need to be displayed a text
                {data: 'template_content'},               
                {data: 'action', orderable: false, searchable: false}
            ]
        });
    }

Aucun commentaire:

Enregistrer un commentaire