Searching functionality not working?
Searching functionality not working?

Hello,
I am using server side code for my datatable, i am also using column level filtering in the datatable but when i type any value in the field their is no request send back to server.
Thank you in advance.
here is my jsfiddle
'''
var table = $('#datatable').DataTable({
"bDestroy": true,
"sScrollX": true,
"oLanguage": {
sProcessing: "<img src='/Images/loader.gif'>"
},
"paging": false,
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"bProcessing": true,
"bServerSide": true,
"processing": true,
"serverSide": true,
"ScrollY": "calcDataTableHeight()",
"Searching": true,
"sAjaxSource": "/Wip/SummaryAjax?month=" + month + "&year=" + year
"sPaginationType": "full_numbers",
"bDeferRender": true,
"iDisplayLength": 10,
//Rendering Columns of the Table.
"columnDefs": [
{
"render": function (data, type, row) {
if (row[20] == 'True') {
return data + "</br><div style='background-color:#FEFC85;width:100%;height:30px;vertical-align:middle'></div> ";
}
else {
return data;
}
},
"targets": 0
},
{
"render": function (data, type, row) {
if (row[20] == 'True') {
return data + "</br><div style='background-color:#FEFC85;width:100%;height:30px;vertical-align:middle'></div> ";
}
else {
return data;
}
},
"targets": 1
},
{
"render": function (data, type, row) {
var dataToconvert = '';
var rowsixteen = '';
if (row[16] == null) {
rowsixteen = ''
}
else {
rowsixteen = row[16];
}
if (data == null) {
dataToconvert = '';
}
else {
dataToconvert = data;
}
if (row[20] == 'True') {
return dataToconvert + "<br /><div style='background-color:#FEFC85; width:100%;height:30px;vertical-align:middle'>" + rowsixteen + "</div>";
}
else {
return data;
}
},
"targets": 2
},
]
});
'''
Answers
You should clean up your initialization is a little bit because you are mixing older and newer dataTables. bserverside and severSide for instance. You only need to use "serverSide" and the latest versions of the code.
So, you are saying that when a user types anything into the search filter, that the ajax is not firing and you are monitoring the request headers and the response body and nothing is happening?
Okay i will clean the code and yes ajax request not firing when i change value in the search field (this is column level filtering) and i am telling it because i have placed breakpoint on the function on which the ajax request is handled.
This is the response
{"C":"d-BB31D32D-DM,0|DN,4|DO,0","M":[]}
This is Request Header (not of same request though)
'''
Accept:text/plain, /; q=0.01
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:__atuvc=1%7C37; ASP.NET_SessionId=x3bzyo2lknrbmgnkajbu1dtx; __RequestVerificationToken=MBtwoKe2zNfY5I-eGvnoONJDwrRTtpTr0FKL_Ui0SfrFML-QCacMdxjsMtytj55GGRCFLif4NqBIlwqJ3HKoHEDNk9XRlHf41_a2Ms-HIdQ1; .ASPXAUTH=2D5164DE80555DDBF242821895A4EB1C7875487EDDD4259EB670B95543955678E0EE2486433F9E8A973E9F01C777E06E3762AAD394F5C352786140271E81F64C5BDE67C1451F2D3B60203F3DA80C9889C77E9EE4545E216B026A13D33A96F195
Host:localhost:1658
Origin:http://localhost:6500
Referer:http://localhost:6500/Wip/Summary
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
'''
But there is no link. Could you please provide a link to a test case (be it on JSFiddle or otherwise) so we can offer some help.
Allan
here it is new <a href="https://jsfiddle.net/lokopi/ayb423fu/">Fiddle</a>
Check it out i am new to this so please bear
Whole page search working though but it is not redrawing the table
I'm getting a Javascript error on that fiddle:
Allan
I am not getting that error
Using the link above, there is indeed a syntax error:
No trailing comma to separate it from the next line.
If I add the required comma to make it valid Javascript, I then get an error stating that
month
is not defined: https://jsfiddle.net/ayb423fu/1/Can you link to a working test case so I can try to offer some help please.
Allan
The fiddle has many errors in it, month not defined, year not defined, missing a reference to the external dataTables.js, etc.
If you turn on your browsers development tools, you should be seeing them in the console when you try to execute the fiddle.