How to reduce the number of default columns in datatables.

How to reduce the number of default columns in datatables.

SammyskillsSammyskills Posts: 1Questions: 1Answers: 0

Please I will like to know how I can reduce/increase the number of columns in the default datatable example. Here's an example: http://live.datatables.net/salodilo/1/edit
Let's say I just want to create a table that has just four columns: Name, Position, Office and Age., how do I go about this? I'm sincerely sorry if this question has been answered before, but I didn't find it. If there's a link to the answer to this question, please paste it here, and I'll give it a go.

I'm very very new to javascript and datatables, please.

Answers

  • matt_rumsey1212matt_rumsey1212 Posts: 51Questions: 8Answers: 0
    edited November 2015

    So within the HTML of your example you will see the following:

    <th>Category</th>
    <th>No. of Active Adverts</th>
    <th>Active Advert IDs</th>
    <th>Closest Expiry Date</th>
    

    now the <th> tag represents the tables header and there is one for each column. Adding more <th> tags (or removing some) will change the amount of columns you have. Bear in mind that each row (<tr>) has the same amount of table data entry (<td>) tags representing each field within the table. Just follow the same order as your column headers to match up the data with the appropriate column.

This discussion has been closed.