2

I am trying to update a custom parameter that I created in a Jquery Data Table in a function outside the .datatable() function.

I created the custom parameter by:

 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.
}

Is this possible. Please Help!

Thanks, Sunmit.

1 Answer 1

3

It is not necessary to overwrite fnServerData parameter. For your purpose overwrite fnServerParams parameter with something like the following lines:

"fnServerParams": function ( aoData ) {
    aoData.push({ "name": "teamId", "value": $("#projectTeams").val() });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.