Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing an extra parameter to Java controller for jQuery datatables
    primarykey
    data
    text
    <p>I am trying to pass a user defined parameter to the Java Controller which acts as a data source to my jquery Data-Table. The point is, i want to do this (pass the parameter) on a change event for a combobox on my jsp.</p> <p>Here is my datatable initialization:</p> <pre><code>var oTable = $('#reqAllQueriesTable') .dataTable( { "sDom": '&lt;"H"l&lt;"projectTeamTools"&gt;frtip&gt;', "bProcessing": true, "bServerSide": true, "sAjaxSource": "query/getQuery", "bPaginate" : true, "bLengthChange": true, "bScrollCollapse" : true, "iDisplayLength" : 10, "bFilter" : true, "bJQueryUI" : true, "sPaginationType" : "full_numbers", "sSearch": "Search" }); </code></pre> <p>My combobox whose values are to be passed to the controller and the respective functions are:</p> <pre><code> $("div.projectTeamTools").html('Organize by Project Teams: &lt;select id="projectTeams"&gt;&lt;option value="0"&gt;Project Team&lt;/option&gt;&lt;option value="1"&gt;All&lt;/option&gt;&lt;option value="2"&gt;Not Associated&lt;/option&gt;&lt;c:forEach var="projectTeam" items="${userProjectTeams}"&gt;&lt;option value="${projectTeam.projectId}"&gt;${projectTeam.projectName}&lt;/option&gt;&lt;/c:forEach&gt;&lt;/select&gt;'); $("#projectTeams").change(function () { onTeamSelect($(this).val()); }); function onTeamSelect(teamId){ alert(teamId +" Selected"); //This function to pass the parameter to the datatable is supposed to be here. oTable.fnDraw(); } </code></pre> <p>The datatable then displays the new data it receives from the ajax Source <code>getQuery</code>.</p> <p>PS: I cannot use fnServerParams as I am using the older version of datatables. I have tried using fnServerData but it did not help. I guess I am wrong in the way I am using the ajax function in fnServerData.</p> <pre><code>"fnServerData": function ( sSource, aoData, fnCallback ) { $("#projectTeams").change(function() { aoData.push( { "name": "myParam", "value": $("#ComboBox option:selected").value() } ); $.ajax( { "dataType": 'json', "url": sSource, "data": aoData, "success": fnCallback }); </code></pre> <p>I cannot see the parameter I want to pass in the 'Network XHR' in my browser when I select an item from the combo-box. Please help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload