Analysis of the use of Bootstrap tables, analysis of bootstrap tables

Source: Internet
Author: User

Analysis of the use of Bootstrap tables, analysis of bootstrap tables

Bootstrap-simple, intuitive, powerful, and mobile device-preferred front-end development framework, making web development faster and simpler. The following describes how to use the Bootstrap table.

First define the front-end table

<table class="table table-striped table-bordered table-hover" id="expandabledatatable"></table> 

Then Javascript

/** Initialize table */var oTable = $ ('# expandableable able '). dataTable ({"sDom": "Tflt <'row DTTTFooter '<'col-sm-6' I> <'col-sm-6 'p>", "aoColumnDefs ": [{"bSortable": false, "aTargets": [0], "render": function (data, type, full) {return '<I class = "fa-plus-square-o row-details"> </I>' ;},{ "aTargets": [1], "data": "TaskName", "title": "Task Name" },{ "aTargets": [2], "data": "CronExpression", "title ": "expression" },{ "aTargets": [3], "data": "Remark", "title": "Description" },{ "bSortable": false, "aTargets": [4], "title": "Running State", "render": function (data, type, full) {if (full ["Enabled"] = true) {return '<button type = "button" class = "btn-success btn-sm"> RUN </button> ';} else {return '<button type = "button" class = "btn-warning btn-sm"> stop </button>' ;}}, {"bSortable ": false, "aTargets": [5], "render": function (data, type, full) {return '<a href = "#" class = "btn-info btn-xs edit"> <I class = "fa-edit"> </I> edit </a> <a href = "#" class = "btn-danger btn-xs delete"> <I class = "fa-trash-o"> </I> delete </a> ';}}], "bServerSide": true, "sAjaxSource": "/Task/GetAllTask", "aaSorting": [[1, 'asc '], "aLengthMenu": [[5, 15, 20,-1], [5, 15, 20, "All"], "iDisplayLength": 5, "searching": false, "bLengthChange": false, "language": {"sProcessing": "loading data... "," sInfoEmpty ":" The number of records is 0 "," sInfoFiltered ":" filter entries from _ MAX _ "," sZeroRecords ":" No content you want to search ", "search": "", "sLengthMenu": "_ MENU _", "sInfo": "data entries from _ START _ to _ END _/TOTAL ", "oPaginate": {"sPrevious": "Previous Page", "sNext": "Next page", }}, "fnServerData": function (sSource, aoData, fnCallback) {$. ajax ({"type": 'post', "url": sSource, "dataType": "json", "data": {aoData: JSON. stringify (aoData)}, "success": function (resp) {fnCallback (resp );}});}});

The data in this table is obtained from the server. Therefore, the following attributes must be configured. Otherwise, data cannot be obtained from the server.

"bServerSide": true,"sAjaxSource": "/Task/GetAllTask","fnServerData": function (sSource, aoData, fnCallback) {$.ajax({"type": 'post',"url": sSource,"dataType": "json","data": {aoData: JSON.stringify(aoData)},"success": function (resp) {fnCallback(resp);}});}

The above is a small Editor to introduce you to the use of Bootstrap tables, I hope to help you, if you have any questions, please leave a message, the small editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.