问题描述
我正在尝试填充我在数据表插件中为JQuery创建的下拉框。我使用的代码是:
var oTable = $('#reqAllQueriesTable')
。 dataTable(
{
sDom:'<H<tools> lfrt>',
});
$(div.tools)html('由团队组织:< select id =booking_status>< option value =>团队< / option>< option value = team1>团队1< / option>< option value =team2>团队2< / option>< / select>');
我要替换的静态内容选择
在HTML中通过我的Java代码中的对象的列表
的内容。
这是否可以通过替换现有的代码?如果是,在该代码中如何使用Java对象。
请帮助。
得到答案。
我从我调用JSP的java代码传递一个模型属性:
model.addAttribute(userTeams userTeams);
然后在jQuery数据表中,我覆盖DOM调用一个 div
命名为 myTools
:
var oTable = $ ('#reqAllQueriesTable')
.dataTable(
{
sDom:'<H<myTools> lfrt>',
});
创建下拉列表的div如下所示:
$(div.myTools)。html('由团队组织:< select id =teams>< option value =>团队< / option>< c:forEach var =userTeamsitems =$ {userProjectTeams}>< option value =$ {userTeams.teamId}onClick =javascript:takeAction(this.value) > $ {userTeams.teamtName}< / option>< / c:forEach>< / select>');
I am trying to populate a drop-down box which I have created in the Data-Tables plug-in for JQuery.The code I have used is:
var oTable = $('#reqAllQueriesTable')
.dataTable(
{
"sDom": '<"H"<"tools">lfrt>',
});
$("div.tools").html('Organize by Teams: <select id="booking_status"><option value="">Teams</option><option value="team1">Team 1</option><option value="team2">Team 2</option></select>');
I want to replace the static contents of select
in HTML by the content by a List
of objects in my Java code.Is this possible by replacing the existing code? If yes, how can the Java object be used in this code.Please help.
Got the answer.I pass a model attribute from my java code which calls the JSP:
model.addAttribute("userTeams",userTeams);
Then in jQuery Data Table, I overwrite the DOM to call a div
named myTools
:
var oTable = $('#reqAllQueriesTable')
.dataTable(
{
"sDom": '<"H"<"myTools">lfrt>',
});
The div which creates the drop-down list looks like:
$("div.myTools").html('Organize by Teams: <select id="teams"><option value="">Team</option><c:forEach var="userTeams" items="${userProjectTeams}"><option value="${userTeams.teamId}" onClick="javascript:takeAction(this.value)"> ${userTeams.teamtName}</option></c:forEach></select>');
这篇关于填充数据表中的自定义下拉框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!