-
-
Notifications
You must be signed in to change notification settings - Fork 14
2. Table Settings
Configuring Jquery datatable settings with helper is very easy.
Calling datatable on client-side is possible with name:
.Name("GridName")
Default name is "DataGrid". If there are multiple grid in single page, different names should be given. Call grid if you need like this:
$(document).ready(function() {
var table = $('#DataGrid').DataTable();
} );
This option allows the search abilities of DataTables to be enabled or disabled. Default is "true". Reference:
.Searching(false)
Enable or disable ordering of columns - it is as simple as that! DataTables, by default, allows end users to click on the header cell for each column, ordering the table by the data in that column. Default is "true". Reference:
.Ordering(false)
DataTables can split the rows in tables into individual pages, which is an efficient method of showing a large number of records in a small space. The end user is provided with controls to request the display of different data as the navigate through the data. Default is "true". Reference:
.Paging(false)
Select adds item selection capabilities to a DataTable. Items can be rows, columns or cells, which can be selected independently, or together. Reference:
.Selecting(true)
.Selecting(true, SelectItems.Checkbox)
.Selecting(true, SelectItems.Cell, SelectStyle.Single)
Enable or disable the display of a 'processing' indicator when the table is being processed. Default is true. Reference:
.Processing(false)
Enable horizontal scrolling. When a table is too wide to fit into a certain layout, or you have a large number of columns in the table, you can enable horizontal (x) scrolling to show the table in a viewport, which can be scrolled. Reference:
.ScrollX(true)
Default table css class is "display nowrap dataTable dtr-inline collapsed"
. It can be replaced with other table class like bootstrap "table table-striped".
.Class("table table-striped")
Adding some text on table header or footer with Captions method that:
.Captions("Top caption text...", "Bottom caption text...")
FixedColumns provides the option to freeze one or more columns to the left or right of a horizontally scrolling DataTable. Reference:
.FixedColumns(leftColumns: 1, rightColumns: 3)
With this feature, data is be searchable column by column if column searchable is not false.
.ColumnSearching(true)
To give class for these inputs:
.ColumnSearching(true, "form-control")