Datatbles modify the display style (modify the row and column background color, Font, and line color)

Source: Internet
Author: User

Here we mainly introduce two functions: aocolumndefs and createdrow.

The usage of datatables is very simple. You can check the information and directly use the code:

VaR T;
T = $ ("# accounttbl"). datatable ({
Searching: True,
Processing: True,
DOM: "<'row' <'col-sm-12 'tr> \ n \ t <'row' <'col-sm-12 col-md-5 'I> <'col-sm-12 col-md-7 datatables_pager 'lp> ",
Language :{
"Info": "display _ start _ to _ end _ total _ records ",
"Infoempty": "display records from 0 to 0 of 0 ",
"Lengthmenu": "_ menu _ records displayed on each page ",
"Emptytable": "No query records ",
"Loadingrecords": "loading ...",
"Zerorecords": "No query records ",
},
// Aocolumndefs :[
// {"Sclass": "col_class", "atargets": [0] },{ "sclass": "cos_class", "atargets": [1]}],
Createdrow: function (row, Data, index ){
If (index % 2 = 0 ){
$ ('Td ', row).css ('font-westight', "bold" 2.16.css ("color", "# c43ff6 ");
}
},
Buttons: ["print", "copyhtml5", "excelhtml5", "csvhtml5", "pdfhtml5"],
Select: True,
Rowid: 'id ',
Serverside: True,
Ajax :{
"Url ":'',
},
Columns :[{
Data: "ID ",
"Orderable": True, "width": "50px"
},
],
})

 

1. aocolumndefs:

This function modifies the Column Display. {"sclass": "col_class", "atargets": [0]}, "atargets" indicates the first column from left to right, the second column is [1]. This col_class needs to be defined on the front end.

<Style>
. Col_class {
Color: # ff7e29;
}
. Cos_class {
Color: #2a1cf6;
}
</Style>
2,Createdrow:
This function is used to modify the row display. createdrow: function (row, Data, index) {}, the three parameters "row" represent the row, and "data" represent the field you passed in, this means that you can filter and display fields based on their content,
Index is the index value of the row.
Line color display:
If (index % 2 = 0 ){
$ ('Td ', row).css ('font-westight', "bold" 2.16.css ("color", "# c43ff6 ");
}
Display by ID:
if ( data[‘id] %2 == 0 ) {
$(‘td‘, row).css(‘font-weight‘,"bold").css("color","#c43ff6");
}
PS: If you want to modify the length of the TD tag, you can restrict it in columns.
 
 columns: [{
data: "id",
"orderable": true,"width":"50px"
},
],
 
 

Datatbles modify the display style (modify the row and column background color, Font, and line color)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.