Kiến thức

columnDefs.targets

columnDefs.targets

Since: DataTables 1.10

Assign a column definition to one or more columns.

Bạn đang xem: columnDefs.targets

Description

The

columnDefs

option allows a column definition object to be defined and then assigned to one or more columns in a DataTable, regardless of the order of the column definitions array, or the order of the columns in the table.

This

columnDefs.targets

option provides the information required by DataTables for which columns in the table the column definition object should be applied.

It can be:

  • 0 or a positive integer – column index counting from the left
  • A negative integer – column index counting from the right
  • A string – class name will be matched on the TH for the column (without a leading .)
  • The string “_all” – all columns (i.e. assign a default)

Additionally, targets can be either a single option from the list above, or an array of options (the different types can be mixed in the array if required). For example targets: [ -1, -2 ] would target the last and second last columns in the table.

Please note that unlike all other column configuration options which can be applied to be

columns

and

columnDefs

, the

columnDefs.targets

option can only be used in

columnDefs

.

Type

This option can be given in the following type(s):

  • array

    or

    string

    or

    integer

Examples

Disable filtering on the first column:

$('#example').dataTable( { "columnDefs": [ { "targets": 0, "searchable": false } ] } );

Disable sorting on the first and third columns:

$('#example').dataTable( { "columnDefs": [ { "targets": [ 0, 2 ], "orderable": false } ] } );

Disable ordering on columns which have a class of ‘nosort’:

$('#example').dataTable( { "columnDefs": [ { "targets": 'nosort', "orderable": false } ] } );

Related

The following options are directly related and may also be useful in your application development.

Chuyên mục: Kiến thức

Related Articles

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Check Also
Close
Back to top button
444 live app 444 live 444 live app 444live kisslive kiss live yy live yylive