fnServerParams
fnServerParams
testacc
Posts: 2Questions: 0Answers: 0
Hello,
I'd like to send different arguements to the "fnServerParams" based on other events. For example;
If I change the select control, I'd like to re-intialize the table and send different fnServerParams containing value of the control.
This is datatable code:
[code] $(document).ready(function () {
var oTable = $('#tblServiceIssue').dataTable({
"bJQueryUI": true,
"sScrollY": "700px",
"bSort": true,
"bServerSide": true,
"bPaginate": false,
"bDeferRender": true,
"bSearchable": true,
"aaSorting": [[1, "asc"]],
"bInfo": false,
"sAjaxSource": "./DataTablePages/frmServiceIssues.aspx",
"fnServerParams": function (aoData) { aoData.push({ "name": "Reason", "value": intSupplierID }) },
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax(
{
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (data) { fnCallback(data); }
});
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [0], "bSearchable": false, "sClass": "ServiceIDX" }, // ServiceEventID
{"sWidth": "50px", "aTargets": [1], "bSearchable": true }, // Service Issue Number
{"sWidth": "75px", "aTargets": [2], "bSearchable": false }, // Date Reported
{"sWidth": "230px", "aTargets": [3], "bSearchable": true }, // Company Reported By
{"sWidth": "300px", "aTargets": [4], "bSearchable": true }, // Address
{"sWidth": "80px", "aTargets": [5], "bSearchable": true }, // Telephone
{"sWidth": "100px", "aTargets": [6], "bSearchable": false }, // Status
{"sWidth": "35px", "aTargets": [7], "bSearchable": false} // Live
]
});[/code]
Any help or suggestions would be much appericated. Thank you.
Regards
I'd like to send different arguements to the "fnServerParams" based on other events. For example;
If I change the select control, I'd like to re-intialize the table and send different fnServerParams containing value of the control.
This is datatable code:
[code] $(document).ready(function () {
var oTable = $('#tblServiceIssue').dataTable({
"bJQueryUI": true,
"sScrollY": "700px",
"bSort": true,
"bServerSide": true,
"bPaginate": false,
"bDeferRender": true,
"bSearchable": true,
"aaSorting": [[1, "asc"]],
"bInfo": false,
"sAjaxSource": "./DataTablePages/frmServiceIssues.aspx",
"fnServerParams": function (aoData) { aoData.push({ "name": "Reason", "value": intSupplierID }) },
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax(
{
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (data) { fnCallback(data); }
});
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [0], "bSearchable": false, "sClass": "ServiceIDX" }, // ServiceEventID
{"sWidth": "50px", "aTargets": [1], "bSearchable": true }, // Service Issue Number
{"sWidth": "75px", "aTargets": [2], "bSearchable": false }, // Date Reported
{"sWidth": "230px", "aTargets": [3], "bSearchable": true }, // Company Reported By
{"sWidth": "300px", "aTargets": [4], "bSearchable": true }, // Address
{"sWidth": "80px", "aTargets": [5], "bSearchable": true }, // Telephone
{"sWidth": "100px", "aTargets": [6], "bSearchable": false }, // Status
{"sWidth": "35px", "aTargets": [7], "bSearchable": false} // Live
]
});[/code]
Any help or suggestions would be much appericated. Thank you.
Regards
This discussion has been closed.
Replies
If I change the select control, I'd like to re-intialize the table and send different fnServerParams containing value of the control.
Rather than reinitialising the table, why not just read the value of the select control in the fnServerParams function? Something like $('#mySelect').val() is all that is needed :-). Then whenever the table is drawn your filter value will be sent - so all you need to do when the select value changes is call fnDraw.
Allan
Thanks alot for your help much appericated, Alan.
Keep up good work with DataTables!