Bootstrap - A simple, intuitive, powerful, mobile-first front-end development framework, making web development faster and simpler. Let’s introduce the use of Bootstrap tables to you below. Let’s learn together.
Define the front-end table first
<table id="expandabledatatable"></table>
Then JS
/** Initialize the table*/var oTable = $('#expandabledatatable').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></i>';}},{ "aTargets": [1], "data": "TaskName", "title": "TaskName" },{ "aTargets": [2], "data": "CronExpression", "title": "Expression" },{ "aTargets": [3], "data": "Remark", "title": "Description" },{"bSortable": false, "aTargets": [4], "title": "Run status","render": function (data, type, full) {if (full["Enabled"]==true){return '<button type="button">Run</button>';}else {return '<button type="button">Stop</button>';}}},{"bSortable": false, "aTargets": [5],"render": function (data, type, full) {return '<a href="#"><i></i> Edit</a> <a href="#"><i></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": "Records are 0","sInfoFiltered": "Filtered from _MAX_bar","sZeroRecords": "Nothing you want to search","search": "","sLengthMenu": "_MENU_","sInfo": "From _START_ to _END_ /Total_TOTAL_bar data","oPaginate": {"sPrevious": "Previous": "Previous","sNext": "Next",}},"fnServerData": function (sSource, aoData, fnCallback) {$.ajax({"type": 'post',"url": sSource,"dataType": "json","data": {aoData: JSON.stringify(aoData)},"success": function (resp) {fnCallback(resp);}});}});The data of this table is obtained from the server side, so the following properties must be configured, otherwise the data cannot be obtained from the server side
"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 the relevant knowledge about the use of Bootstrap forms introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!