DataTables load dynamic table with Ajax __ajax

Source: Internet
Author: User

The following files need to be introduced

<script src= "<%=request.getcontextpath ()%>/static/js/plugins/datatables/datatables.min.js" ></ Script>

I might also need a jquery file, but I've got too many projects to introduce, and if I don't see the table properly, please introduce yourself to other required files.

 <table class= ' table table-bordered jambo_table bulk_action table-striped table-hover ' id= ' dat Alist ">//style must be written on <thead> <tr class=" headings ">     <th>   &nb
	sp; <th width= "10%" > Regulatory file name </th>     <th width= "10%" > Keyword </th>     <th width= "20%" > enacting agency </th>     <th width= "10%" > Date of promulgation </th>     <th width= "10%" > Document attachments </th>     <th width= "10 % > Release status </th>     <th width= "10%" > Audit status </th>     < Th width= "10%" > Operation </th>     <th width= "10%" > function </th> </tr> </th Ead> <tbody>//ajax requested JSON format data padding     </tbody> </table> 

<thead></thead> tag is DataTables's head,<tbody></tbody> is data, which is populated with Ajax-requested JSON format data, so it's not written.

Next Initialize the DataTable

$ (' #dataList '). DataTable ({"Autowidth": false,//when the table is repeatedly refreshed, my page will appear distorted, the phenomenon, add this is good "serverside": True, "Ajax": {Url:const_url. LIST,//Requested URL method: "POST", data: {//Requested parameter Larename: $ (' #lareName '). Val (), KeyWord: $ (' #keyWord '). Val (), I Ssunitname: $ (' #issUnitName '). Val (), Repstat: $ (' #repStat '). Val (), Veristat: $ (' #veriStat '). Val (), StartDate: $ (' #startDate '). Val (), EndDate: $ (' #endDate '). Val (),},}, "Columndefs": [//Definition of table format (table column starting from 0) {"Ta Rgets ": 0,//This column is an ID, but do not want to display the front end," visible ": false, which means hide" visible ": false,}, targets:8,//according to the style fa-pencil-square, the  The 8th column shows the style of an icon render:function (data, Type,row) {return ' <i class= "fa fa-pencil-square text-navy" Guid= "' +row.guid+ '" ></i>   ' + ' <i class= "fa fa-trash text-danger fa-lg" guid= "' +row.guid+ '"
			   Gt;</i> '; {targets:9,//changes the style in column nineth to hyperlink render:function (data, type, row) {return ' <a href= ' > Audit </a> '; }], "columns": [//The returned JSON data is populated here, be sure to correspond to the <th> number above, otherwise typographical distortion {"Data": "Gu ID "}, {" Data ":" Larename "}, {" Data ":" KeyWord "}, {" Data ":" Issunitname "}, {" Data ":" Reletime "} , {"Data": "Laretype"}, {"Data": "Repstat"}, {"Data": "Veristat"}]});

Related Article

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.