-
Notifications
You must be signed in to change notification settings - Fork 78
columns()
As of v1.2.0
, the columns
API is implemented and allows access to the table columns for quick manipulation.
The API allows for the selection of columns by passing either a single integer
representing a column index or and array
of integer
s representing multiple column indexes tot eh columns()
constructor:
// Select the first, fourth and sixth columns
var columns = datatable.columns([0,3,5]);
You may select all columns by leaving omitting the selection:
// Select all columns
var columns = datatable.columns();
You can then chain the following methods.
Hides the selected column(s). The columns will not be visible and will be omitted from search results and exported data.
// Hide the first and second columns
var columns = datatable.columns([0,1]);
columns.hide();
// or just
datatable.columns([0,1]).hide();
Shows the selected column(s) (if hidden). The columns will be visible and will be included in search results and exported data.
// Show the first and second columns
var columns = datatable.columns([0,1]);
columns.show();
// or just
datatable.columns([0,1]).show();
Checks to see if the selected column(s) are visible. Returns a boolean
for single indexes or an array
of boolean
s for multiple indexes.
// Select the fourth column
var columns = datatable.columns(3);
// Hide it
columns.hide();
// Check visiblilty
columns.visible() // returns false
or
datatable.columns().visible() // returns [true, true, true, false, true]
Checks to see if the selected column(s) are visible. Returns a boolean
for single indexes or an array
of boolean
s for multiple indexes.
Order the columns based on the given order. Just pass an array of column indexes in the order you require. Note that as this method is for setting the order on all columns, you don't need to pass the selected columns to the columns()
constructor and any that are, will be ignored.
// Reorder the columns
datatable.columns().order([1,3,4,2,0]);
- datatable.init
- datatable.refresh
- datatable.update
- datatable.page
- datatable.sort
- datatable.perpage
- datatable.search
- perPage
- perPageSelect
- nextPrev
- prevText
- nextText
- firstLast
- firstText
- lastText
- searchable
- sortable
- truncatePager
- fixedColumns
- fixedHeight
- columns
- data
- ajax
- labels
- layout
- header
- footer
- table
- head DEPRECATED
- body DEPRECATED
- foot DEPRECATED
- wrapper
- container
- pagers
- headings
- options DEPRECATED
- initialized
- isIE DEPRECATED
- data
- activeRows DEPRECATED
- dataIndex
- pages
- hasRows
- hasHeadings
- currentPage
- totalPages
- onFirstPage
- onLastPage
- searching
- searchData