2

我使用您可以在此处找到的代码在 J-Query 数据表上创建了一个自定义标题。I want to add a custom parameter to the data table when a particular item from the drop-down box is selected.

以下是我的代码:

$(function() {
  var oTable = $('#reqAllQueriesTable')
    .dataTable({
      "bProcessing": true,
      "bServerSide": true,
      "sAjaxSource": "query/getQuery",
      "bFilter": true,
      "bJQueryUI": true,
      "sSearch": "Search",
      "sDom": '<"H"<"projectTeamTools">lrft>'
    });

  $("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.aoServerParams.push({
    name: "aoTeamId",
    value: teamId
  }); //This line does not work.
}
<link href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>

<table id="reqAllQueriesTable"></table>

onTeamSelect()函数被正确调用并显示警报。但是我想将 custm 参数添加aoTeamId到数据表中,并将值传递给getQuery我用来填充数据表的控制器。这可能吗?请帮忙!

4

0 回答 0