Can multiple columns in a datatable shara a common Header/Title??

Can multiple columns in a datatable shara a common Header/Title??

dt8485dt8485 Posts: 7Questions: 0Answers: 0
edited August 2011 in DataTables 1.8
I have a 5 columns in a dataTable and one them have a sTitle:"Action". Can I have the other 4 columns to share the same this same title.

Below is my code:

dataTable = $('#usersTable').dataTable({
"bJQueryUI": true,
"aaData": userData,
"oLanguage": {
"sZeroRecords": "No Records Found"
},
"bDestroy": true,
"aoColumns": [{ "sTitle": "Full Name", "mDataProp": "FullName" }, { "sTitle": "UserName", "mDataProp": "UserName" },
{ "sTitle": "Email", "mDataProp": "Email" }, { "sTitle": "Role", "mDataProp": "RoleName" },
{ "sTitle": "Action", "sClass": "control center", "mDataProp": null, "sDefaultContent":
'View Details'
},
{ "sClass": "control center", "mDataProp": null, "sDefaultContent":
''
},
{ "sClass": "control center", "mDataProp": null, "sDefaultContent":
''
},
{ "sClass": "control center", "mDataProp": null, "sDefaultContent":
''
},
{ "sClass": "control center", "mDataProp": null, "sDefaultContent":
' '
}
]

});

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    [quote]dt8485 said: Can I have the other 4 columns to share the same this same title. [/quote]

    Not sure what you mean by share the same title. Can you explain? Do you mean have the header colspan=4 for these columns?
  • dt8485dt8485 Posts: 7Questions: 0Answers: 0
    Yes, I want all the 4 columns to share the same header "Action"
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you need each column to have it's own TH in the header for one row, but if you use multiple rows, you can group elements with a colspan:

    http://www.datatables.net/release-datatables/examples/basic_init/complex_header.html
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited August 2011
    maybe you could leave the sTitle blank for headers you don't want to see, and bSortable: false so no arrows show up, which might make that row not look visible to users.

    [code]


    ID
    Action








    [/code]
This discussion has been closed.