Bootstrap classes doesn't work with ajax data?

Bootstrap classes doesn't work with ajax data?

sergedasergeda Posts: 42Questions: 16Answers: 0

When I have my table rendered with data I use col-md-1, col-md-2 etc classes to set width for each column. But after I switch to ajax data now this classes doesn't work. How can I set width for each column?

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Where are you using those since they do not apply to the table itself? You might need to use the dom option to better define how the classes are used.

    We need to see your code to figure out what you are doing.

  • sergedasergeda Posts: 42Questions: 16Answers: 0

    I appy them to th like this:

                                    <thead>
                                        <tr><th class="col-md-1">#</th>
                                            <th class="col-md-4">Name</th>
                                            <th class="col-md-1">Action</th> </tr>
                                    </thead>
    

    But with ajax data this doesn't work

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    In all honesty, you are miss using the classes, they are intended to be used in a div container with div rows and columns.

    If you want to set certain widths, either add widths in columnDefs or columns options or define a class and set that with className in one of the two above options.

    Some more info here https://datatables.net/reference/option/columns.width

  • sergedasergeda Posts: 42Questions: 16Answers: 0

    Thanks a lot

This discussion has been closed.