aoData and sSearch_X values
aoData and sSearch_X values
MrBaseball34
Posts: 96Questions: 0Answers: 0
I need to set the initial sSearch values. when I do this:
[code]
aoData.push({"name":"sSearch_9", "value":"{segment_2}"}
, {"name":"sSearch_18", "value":"{segment_3}"}
, {"name":"sSearch_19", "value":"{segment_4}"}
, {"name":"sSearch_20", "value":"{segment_5}"});
[/code]
It actually places another parameter on the stack with the same name.
How would I change the original value?
The {segment_X} values are from ExpressionEngine. We are using the URL path, which is what the segment_X values are for, to set the filtering like this:
http://ourURL.com/page/segment_2/segment_3/segment_4/segment_5
This allows our users to use the back button to go to previous searches (filters) and also to send the URL to others with the filter intact.
[code]
aoData.push({"name":"sSearch_9", "value":"{segment_2}"}
, {"name":"sSearch_18", "value":"{segment_3}"}
, {"name":"sSearch_19", "value":"{segment_4}"}
, {"name":"sSearch_20", "value":"{segment_5}"});
[/code]
It actually places another parameter on the stack with the same name.
How would I change the original value?
The {segment_X} values are from ExpressionEngine. We are using the URL path, which is what the segment_X values are for, to set the filtering like this:
http://ourURL.com/page/segment_2/segment_3/segment_4/segment_5
This allows our users to use the back button to go to previous searches (filters) and also to send the URL to others with the filter intact.
This discussion has been closed.
Replies
for (i in aoData) {
switch(aoData[i].name) {
case "sSearch_9": aoData[i].value="{segment_2}"; break;
case "sSearch_18": aoData[i].value="{segment_3}"; break;
case "sSearch_19": aoData[i].value="{segment_4}"; break;
case "sSearch_20": aoData[i].value="{segment_5}"; break;
}
}
[/code]
Definition:
[code]
oTable = $('#scheduleTable').dataTable( {
"oLanguage": {
"sInfoFiltered": ""
},
"sPaginationType": "full_numbers",
"bProcessing": true,
"bJQueryUI": true,
"bServerSide": true,
"aaSorting": [],
"sAjaxSource": "/files/schedule_filter.php",
"aoColumns": [null /* Location */
, { "iDataSort": 17 } /* FormalDate */
, null /* Program_Title */
, null /* Price */
, null /* Information */
, { "bVisible": false } /* ProgramCode */
, { "bVisible": false } /* ProgramGroup */
, { "bVisible": false } /* EventCode */
, { "bVisible": false } /* LocCity */
, { "bVisible": false } /* LocState */
, { "bVisible": false } /* LocAddress */
, { "bVisible": false } /* LocName */
, { "bVisible": false } /* LicenseeURL */
, { "bVisible": false } /* GateKeeper_length */
, { "bVisible": false } /* SeatsAreAvailable */
, { "bVisible": false } /* LocLatitude */
, { "bVisible": false } /* LocLongitude */
, { "bVisible": false
, "sType": "date" } /* StartDate */
, { "bVisible": false } /* Months */
, { "bVisible": false } /* Zip_Code */
, { "bVisible": false } /* Programs */
],
"sDom": '<"top">rt<"bottom"ilp><"clear">',
"fnServerData": function( sSource, aoData, fnCallback ) {
for (i in aoData) {
switch(aoData[i].name) {
case "sSearch_9": aoData[i].value="{segment_2}"; break;
case "sSearch_18": aoData[i].value="{segment_3}"; break;
case "sSearch_19": aoData[i].value="{segment_4}"; break;
case "sSearch_20": aoData[i].value="{segment_5}"; break;
}
}
aoData.push({"name":"debug", "value":"no"});
$.ajax( {"dataType": 'json'
, "type": "POST"
, "url": sSource
, "data": aoData
, "success": fnCallback
} );
}
} );
[/code]
Setting the filter dynamically like this:
[code]
$("#state").blur(function() {
var src = $(this).val();
oTable.fnFilter(src, 9);
});
$("#months").blur(function() {
var src = $(this).val();
oTable.fnFilter(src, 18);
});
$("#programs").blur(function() {
var src = $(this).val();
oTable.fnFilter(src, 19);
});
$("#zip").blur(function() {
var src = $(this).val();
oTable.fnFilter(src, 20);
});
[/code]
But sSearch_9 is never set when typing in a value and exiting the #state input.
and looking in the debugger, value was set for sSearch_9
chrome 12