Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Jquery Datatable - dynamically adding class to specific columns

In Jquery Datatable, I am trying to add a class named "control" in specific columns but it seems not working. I do not see any errors.

I am selecting columns by using class name (all) and then trying to add another class "control". Please see the code below,

public static CreateTableView(tableId: string) {
    let dataTable = $(tableId).DataTable({
        deferRender: true,
        scrollY: '200px',
        scrollX: false,
        scrollCollapse: true,
        searching: false,
        paging: false,
        info: false,
        columns: [
            { title: "Name", data: "Name" className: "all" },
            { title: "Age", data: "Age" },
            { title: "Serial Number", data: "Serial" },
            { title: "Description", data: "Descritption", className: "all" },                         
            { title: "Errors", data: "Notes", className: "all" }                
        ],
        responsive: {
            details: {
                type: 'none',
                target: '.btn-link',
                display: GetDetailsDialogDisplay(tableId),
                renderer: $.fn.dataTable.Responsive.renderer.tableAll({
                    tableClass: 'table'
                })
            }
        },
        order: [1, 'asc'],
        select: {
            style: 'single',
            selector: 'td .btn-link',
            className: 'selected bg-selected-row'
        }
    });


    $(tableId).off('click', '.btn-link').on('click', '.btn-link', function () {

        dataTable.columns('.all').to$().addClass('control');
    });

    return dataTable;
}; 

Any suggestion / direction will be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!