2

我正在尝试更新我在函数外部.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.
}

这可能吗。请帮忙!

谢谢,桑米特。

4

1 回答 1

3

不需要覆盖 fnServerData 参数。出于您的目的,使用类似于以下行的内容覆盖 fnServerParams 参数:

"fnServerParams": function ( aoData ) {
    aoData.push({ "name": "teamId", "value": $("#projectTeams").val() });
}
于 2013-01-14T15:34:55.143 回答