我想将组合框和文本字段数据加载到网格中。
怎么做?
上图:选择第 1 列中的框数据和第 2 列中的文本框数据。
这是我的 Jsp 网格代码:
<s:url id="remoteurl" action="" />
<sjg:grid caption="RECORDS"
gridModel="dto_plot_rep"
width="300" height="80"
href="%{remoteurl}"
id="gridtable2"
rownumbers="true"
viewrecords="true"
pager="true"
pagerPosition="centar"
navigator="true"
navigatorSearch="true"
navigatorSearchOptions="{multipleSearch:true}"
navigatorDelete="false"
navigatorEdit="false"
loadonce="true"
onCompleteTopics="cal_tot"
userDataOnFooter="true"
reloadTopics="reloadPlot"
rowNum="10"
>
<sjg:gridColumn name="m_tab_p" index="m_tab_p" title="P" width="180" align="left" search="true" searchoptions="{sopt:['eq','cn']}" sortable="true"/>
<sjg:gridColumn name="m_tab_ce" index="m_tab_c" title="C" width="180" align="left" search="true" searchoptions="{sopt:['eq','cn']}" sortable="true"/>
</sjg:grid>
最佳答案
addRowData
方法允许您将行添加到 jqgrid 中。 Docs .
假设您可以将表单中的数据捕获到数组中 arr = [2, 4.0]
您可以按如下方式插入行:
<button id="add" type="button">ADD</button>
<script>
$("#add").click(function(){
arr = [2, 4.0]; //You will need to populate this array based on values of your form
lastId = parseInt($(#gridId).getDataIDs().length) + 1;
$("#gridId").jqGrid('addRowData',lastId, arr, "last");
});
</script>
关于jquery - 如何手动加载jqgrid中的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24603337/