jQuery Datatables Bindings
Namespace
WebExtras.JQDataTables
Dependancies
- Appropriate third party libraries
- jquery.dataTables.bootstrap3.js
- jquery.dataTables.bootstrap3.css
- webextras.bootstrap3.css
Steps involved in creating a Datatable
- Creating the column definitions
- Creating the table settings
- Creating the table records
- Creating the table object
- And finally the output.....
Creating column definitions
Column definitions are created by instantiating the
WebExtras.JQDataTables.AOColumn class
AOColumn dtColumn = new AOColumn
{
sTitle = "First Column",
bSortable = true,
sClass = "",
sWidth = "10%",
bVisible = true
};
Creating table settings
Table settings are created by instantiating the
WebExtras.JQDataTables.DatatableSettings class
AOColumn[] dtColumns = new AOColumn[] { dtColumn };
DatatableSettings dtSettings = new DatatableSettings
(
5,
dtColumns,
new AASort(0, SortType.Ascending),
null,
"basic records",
"150px"
);
Creating table records
Table records are created by instantiating the
WebExtras.JQDataTables.DatatableRecords class
string[][] dtData = new string[][]
{
new string[] { "first column row 1" },
new string[] { "first column row 2" }
};
DatatableRecords dtRecords = new DatatableRecords
{
iTotalRecords = dtData.Length,
iTotalDisplayRecords = dtData.Length,
aaData = dtData
};
Creating the table object
Let us now bring all the different components together
Datatable dtable = new Datatable("demo-table", dtSettings, dtRecords);
Now let's see the output
First Column |
Second Column |
first column row 1 | second column row 1 |
first column row 2 | second column row 2 |
first column row 3 | second column row 3 |
first column row 4 | second column row 4 |