jQuery code snippet:
// create server side processing dataTable with jquery cms_table plugin
var sample_server_list = $("#sample-server-list").cms_table({
api: '/cms/files/guide/jquery/api/usr/lst' // RESTful api URL address for dataTable server-side processing
});
HTML code snippet:
<div class="cms_dataTable">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="sample-server-list">
<thead>
<tr>
<th class="sample-jquery-table-th-0"><input type="button" value="+" class="cms-display-select" style="font-size:14px"></th>
<th class="sample-jquery-table-th-1">No</th>
<th class="sample-jquery-table-th-2">ID</th>
<th class="sample-jquery-table-th-3">UID</th>
<th class="sample-jquery-table-th-4">Last</th>
<th class="sample-jquery-table-th-5">First</th>
<th class="sample-jquery-table-th-6">Mail</th>
<th class="sample-jquery-table-th-7">Country</th>
<th class="sample-jquery-table-th-8">City</th>
</tr>
</thead>
</table>
</div>
API URL: "/cms/files/guide/jquery/api/usr/lst" returns JSON data:
{"draw":1,"recordsTotal":"11","recordsFiltered":"11","data":[["<input type=\"checkbox\">",1,"3","anba","Banducci","Annet","Banducci.Annet@mail.com","USA","Boston"],["<input type=\"checkbox\">",2,"1","anjo","Abela","John","Abela.John@mail.com","USA","Boston"],["<input type=\"checkbox\">",3,"7","clge","Georgas","Clark","Georgas.Clark@mail.com","UK","London"],["<input type=\"checkbox\">",4,"8","erha","Harding","Eric","Harding.Eric@mail.com","USA","Long Beach"],["<input type=\"checkbox\">",5,"4","gebr","Braun","George","Braun.George@mail.com","USA","Ashburn"],["<input type=\"checkbox\">",6,"2","hesm","Smith","Helmut","Helmut.Smith@mail.com","USA","New York"],["<input type=\"checkbox\">",7,"10","leko","Kolsrud","Lena","Kolsrud.Lena@mail.com","Germany","Berlin"],["<input type=\"checkbox\">",8,"5","micu","Cunningham","Michael","Cunningham.Michael@mail.com","Canada","Ottawa"],["<input type=\"checkbox\">",9,"6","niva","Vavilov","Nikolay","Vavilov.Nikolay@mail.com","Russia","Moscow"],["<input type=\"checkbox\">",10,"11","raja","Jankowski","Radoslaw","Jankowski.Radoslaw@mail.com","Poland","Warsaw"]],"return":[],"rc":"0","msg":"success"}
API URL page XML definition in pages.xml file:
<doc><url>/usr/lst</url><method>GET</method><fnc>sample_class::usrList</fnc></doc>
Full subsite (based on KUSoftas CMS) configuration and PHP code of sample RESTful API can be found in folder: /cms/files/guide/jquery/api (see using CMS tool "Files": http://www.kusoftas.com/cms/srv/admin/doc)
jQuery code snippet:
// create simple list dataTable with jquery cms_table plugin
var sample_simple_list = $("#sample-simple-list").cms_table({
type: 'list', // type list
options: {
columnDefs: [
{ width: "1%", targets: [0,1]}, // to be small width
{ wisible: false, targets: [2] }, // set ivcisible table id column
{ orderable: false, targets: [0,1,2] }, // make non sortable columns
],
autoWidth: false, // disable column auto width
order: [[ 3, "asc" ]] // initial sorting column
}
});
// user list
var usr_list = [
["<input type=\"checkbox\"\/>",1,"3","anba","Banducci","Annet","Banducci.Annet@mail.com","USA","Boston"],
["<input type=\"checkbox\"\/>",2,"1","anjo","Abela","John","Abela.John@mail.com","USA","Boston"],
["<input type=\"checkbox\"\/>",3,"7","clge","Georgas","Clark","Georgas.Clark@mail.com","UK","London"],
["<input type=\"checkbox\"\/>",4,"8","erha","Harding","Eric","Harding.Eric@mail.com","USA","Long Beach"],
["<input type=\"checkbox\"\/>",5,"4","gebr","Braun","George","Braun.George@mail.com","USA","Ashburn"]
];
// add data from user_list to sample_simple_list
for (var i=1; i<=usr_list.length; i++) {
sample_simple_list.DataTable().row.add(usr_list[i-1]);
}
HTML code snippet:
<div class="cms_dataTable sample-jquery-table">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="sample-simple-list">
<thead>
<tr>
<th><input type="button" value="+" class="cms-display-select" style="font-size:14px"></th>
<th>No</th>
<th>ID</th>
<th>UID</th>
<th>Last</th>
<th>First</th>
<th>Mail</th>
<th>Country</th>
<th>City</th>
</tr>
</thead>
</table>
</div>
jQuery code snippet:
// create ajax list dataTable with jquery cms_table plugin
var sample_ajax_list = $("#sample-ajax-list").cms_table({
type: 'list', // type list
options: {
columnDefs: [
{ width: "1%", targets: [0,1]}, // to be small width
{ wisible: false, targets: [2] }, // set invisible table id column
{ orderable: false, targets: [0,1,2] }, // make non sortable columns
],
autoWidth: false, // disable column auto width
order: [[ 3, "asc" ]], // initial sorting column
ajax: 'http://' + window.location.host + '/cms/files/guide/jquery/api/usr/get' // RESTful api URL address for dataTable Ajax source
}
});
HTML code snippet:
<div class="cms_dataTable">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="sample-ajax-list">
<thead>
<tr>
<th><input type="button" value="+" class="cms-display-select" style="font-size:14px"></th>
<th>No</th>
<th>ID</th>
<th>UID</th>
<th>Last</th>
<th>First</th>
<th>Mail</th>
<th>Country</th>
<th>City</th>
</tr>
</thead>
</table>
</div>
API URL: "/cms/files/guide/jquery/api/usr/get" returns JSON data:
{"data":[["<input type=\"checkbox\" \/>",1,"1","anjo","Abela","John","Abela.John@mail.com","USA","Boston"],["<input type=\"checkbox\" \/>",2,"2","hesm","Smith","Helmut","Helmut.Smith@mail.com","USA","New York"],["<input type=\"checkbox\" \/>",3,"3","anba","Banducci","Annet","Banducci.Annet@mail.com","USA","Boston"],["<input type=\"checkbox\" \/>",4,"4","gebr","Braun","George","Braun.George@mail.com","USA","Ashburn"],["<input type=\"checkbox\" \/>",5,"5","micu","Cunningham","Michael","Cunningham.Michael@mail.com","Canada","Ottawa"],["<input type=\"checkbox\" \/>",6,"6","niva","Vavilov","Nikolay","Vavilov.Nikolay@mail.com","Russia","Moscow"],["<input type=\"checkbox\" \/>",7,"7","clge","Georgas","Clark","Georgas.Clark@mail.com","UK","London"],["<input type=\"checkbox\" \/>",8,"8","erha","Harding","Eric","Harding.Eric@mail.com","USA","Long Beach"],["<input type=\"checkbox\" \/>",9,"9","sthr","Harrison","Stephen","Harrison.Stephen@mail.com","USA","Las Vegas"],["<input type=\"checkbox\" \/>",10,"10","leko","Kolsrud","Lena","Kolsrud.Lena@mail.com","Germany","Berlin"],["<input type=\"checkbox\" \/>",11,"11","raja","Jankowski","Radoslaw","Jankowski.Radoslaw@mail.com","Poland","Warsaw"]]}
API URL page XML definition in pages.xml file:
<doc><url>/usr/get</url><method>GET</method><fnc>sample_class::usrGet</fnc></doc>
Full subsite (based on KUSoftas CMS) configuration and PHP code of sample RESTful API can be found in folder: /cms/files/guide/jquery/api (see using CMS tool "Files": http://www.kusoftas.com/cms/srv/admin/doc)
.cms_table()
Option | Method | Callback |
---|---|---|
type | load | |
nColumnIndex | ||
api | ||
options | ||
messages |
.cms_table( [settings] )
Returns: dataTable()
|
|||||||||
|
There are a number of ways in which DataTables allows you to style tables:
More detailed information about dataTable styling you can find at site http://datatables.net/styling
cms_table plugin has its own additional elements for styling and control:
Plugin cms_table depends on following jQuery packages: