jquery - Ajax table wont filter searches with Datatable pluggin -
i have ajax call create html data , call .datatable html table. when trying make have multiple filters (each column) search function doesn't seem work , when type in returns nothing. below code
$.ajax({ type: "get", url: "wcf/wicsreports.svc/userusagereport?unit=" + unittype + "&startdate=01/09/2014&enddate=01/01/2015&tradingparty=" + tradingpartyval($("#ctl00_contentplaceholder1_csusagelviuser_ddltradingparties")), contenttype: "application/json", // content type sent server success: function (result) { $('.divlviuserreportdata').html(result.userusagereportresult); $('.loading').hide(); // setup - add text input each footer cell $('#lvidetails tfoot th').each(function () { var title = $('#lvidetails thead th').eq($(this).index()).text(); $(this).html('<input type="text" placeholder="search ' + title + '" />'); }); // datatable var table = $('#lvidetails').datatable({ //"bfilter": false, "bpaginate": true, "blengthchange": false, "paging": 50, "pagingtype": "simple", "aasorting": [[1, "asc"]], initcomplete: function () { //$("#lvidetails_filter").hide(); var r = $('#lvidetails tfoot tr'); r.find('th').each(function () { $(this).css('padding', 8); }); $('#lvidetails thead').append(r); $('#search_0').css('text-align', 'center'); }, }); // apply search table.columns().every(function () { var = this; $('input', this.footer()).on('keyup change', function () { .search(this.value) .draw(); }); }); }, error: function (result) { $('.divlviuserreportdata').html("<div class='error_messages'>error: ajax service call failed: " + result.status + " " + result.statustext + "</div>"); $('.loading').hide(); }, beforesend: function () { $('.loading').show(); }, aftersend: function () { } });
any how fix this??
Comments
Post a Comment