1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| var options = { "processing": true, "paging": true, "searching": true, "bFilter": false, "bDestroy": true, "scrollY": "455px", "scrollX": true, "scrollCollapse": true, "ajax": { "url": 'apiurl', "type": "POST", "dataType": "json", "data": { "QueryMediaType": $('#hidSelMediaType').val() } }, "columns": ColumnsRule, "lengthMenu": [[10, 15, 25, 50, -1], [10, 15, 25, 50, "All"]], columnDefs: [ { targets: 0, render: function (e) { return '<button type=\'button\' class=\'btn btn-info btn-sm\' data-toggle=\'modal\' data-target=\'#exampleModal\' onclick="AddObservableList(\'' + e + '\')" >加入觀察</button>'; } } ], "order": [[3, "desc"]], "initComplete": function (settings, json) { hideLoadMask(); } };
var allSetting = responseJson.Data[0].FieldSetting.split('.');
for (var i = 1; i < allSetting.length; i++) { options.columnDefs.push( { visible: allSetting[i-1] == '0' ? false:true, targets: i }); }
MasterTable = $('#example').DataTable(options);
|