我正在尝试更新我在.datatable()
函数之外的函数中在Jquery数据表中创建的自定义参数。
我通过以下方式创建了自定义参数:
var oTable = $('#reqAllQueriesTable')
.dataTable(
{
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "query/getQuery",
"bFilter" : true,
"bJQueryUI" : true,
"sSearch": "Search",
"sDom": '<"H"<"projectTeamTools">lrft>',
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "myParam", "value": "myValue" } );
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
$("div.projectTeamTools").html('Organize by Project Teams: <select id="projectTeams"><option value="1">Project Team</option><c:forEach var="projectTeam" items="${userProjectTeams}"><option value="${projectTeam.projectId}" onClick="javascript:onTeamSelect(this.value)">${projectTeam.projectName}</option></c:forEach></select>');
function onTeamSelect(teamId){
alert(teamId +" Selected");
//oTable.fnSettings().aoServerParams.push( { name: "aoTeamId", value: teamId } );
//I want to update the parameter `myParam` here.
//Or create a new parameter 'aoTeamId', whichever is possible.
}
这可能吗?请帮助!
谢谢, Sunmit。
答案 0 :(得分:3)
没有必要覆盖fnServerData参数。为了您的目的,使用以下行覆盖fnServerParams参数:
"fnServerParams": function ( aoData ) {
aoData.push({ "name": "teamId", "value": $("#projectTeams").val() });
}