datatable ajax search,javascript - DataTables Ajax Search - Stack Overflow

I'm working on a project that uses the DataTables jQuery plugin alongside PHP and MySQL.

I currently have a table that pulls data via an AJAX request and reads the JSON response.

$('#example1').dataTable( {

"processing": false,

"serverSide": true,

"pageLength": 10,

"bFilter": false,

"aaSorting": [[1,'desc']],

"columnDefs": [

{ "width": "10%", "targets": 0 },

{ "width": "100%", "targets": 1 },

{ "width": "220%", "targets": 2 },

{ "width": "130%", "targets": 3 },

{ "width": "180%", "targets": 4 }

],

"responsive": true,

"dom": '>rt>',

"ajax": "ajax.parser.php?ajax_request=assignmentlist",

"fnDrawCallback" : function(oSettings) {

var total_count = oSettings.fnRecordsTotal();

var columns_in_row = $(this).children('thead').children('tr').children('th').length;

var show_num = oSettings._iDisplayLength;

var tr_count = $(this).children('tbody').children('tr').length;

var missing = show_num - tr_count;

if (show_num < total_count && missing > 0){

for(var i = 0; i < missing; i++){

$(this).append('

 ');

}

}

if (show_num > total_count) {

for(var i = 0; i < (total_count - tr_count); i++) {

$(this).append('

 ');

}

}

}

});

I would like to place a mixture of input boxes and select boxes at the top of the table to pass into the AJAX request so that I can perform a search directly in the database. I'm not sure on how to do this with my limited knowledge of the plugin.

What I want to achieve is something like this:

However, this doesn't show how to perform the action when the datasource is a JSON response, nor does it allow me to control the options in the select boxes.

Thanks in advance...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值