fnServerParams blank value passed to server when table is loaded
fnServerParams blank value passed to server when table is loaded
jenny_delta
Posts: 3Questions: 0Answers: 0
I'm loading my datatable in a modal window from a click on an event from the fullcalendar plugin. e.g. user clicks the event, should load a modal window with records from the server. I'm using fnServerParams to send the selected event id to the server to select only records pertaining to that event for loading in the table.
The value of cteid is set before the modal dialog is opened. cteid is a hidden field on the modal form.
But on the first call to the modal form and first display of the table, cteid is blank is being passed to the server as a blank value.
How can I set this value on the fly so that my table will load with only data for the selected event.
[code]
// Catering modal window.
$( "#dialog-catering" ).dialog({
autoOpen: false,
height: 350,
width: 700,
modal: true,
buttons: {
"Add A Break": function() {
$( "#dialog-add-break" ).dialog( "open" );
},
"Done": function() {
$( this ).dialog( "close" );
}
}
});
// Catering table.
var cTable = $('#catering-table').dataTable({
"bPaginate": false,
"bInfo": false,
"bFilter": false,
"bServerSide": true,
"sAjaxSource": "./serverside/get_event_catering.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name" : "cteid", "value" : $( "#cteid" ).val() } );
},
});
[/code]
The value of cteid is set before the modal dialog is opened. cteid is a hidden field on the modal form.
But on the first call to the modal form and first display of the table, cteid is blank is being passed to the server as a blank value.
How can I set this value on the fly so that my table will load with only data for the selected event.
[code]
// Catering modal window.
$( "#dialog-catering" ).dialog({
autoOpen: false,
height: 350,
width: 700,
modal: true,
buttons: {
"Add A Break": function() {
$( "#dialog-add-break" ).dialog( "open" );
},
"Done": function() {
$( this ).dialog( "close" );
}
}
});
// Catering table.
var cTable = $('#catering-table').dataTable({
"bPaginate": false,
"bInfo": false,
"bFilter": false,
"bServerSide": true,
"sAjaxSource": "./serverside/get_event_catering.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name" : "cteid", "value" : $( "#cteid" ).val() } );
},
});
[/code]
This discussion has been closed.
Replies
1. Event is selected
2. cteid hidden field value is set to event.id (has value at this point
3. form is opened
4. table is displayed - should show records for selected event, but shows no data
5. examination of server side shows that cteid is passed to the server as a blank value
Just needed to redraw the table before the form is opened.
Silly me!!