日期:2014-05-17  浏览次数:20612 次

dhtmlxgrid的JSON,xml,table封装数据格式
table格式的,完全和action脱离了,纯粹的JSP页面显示//初始表格
function gridInit(){

    var mygrid = new dhtmlXGridFromTable('gridbox');

    mygrid.setSkin("light");

}
//分页函数
function jumpPage(pageNo, totalPage) {
if (pageNo <= 1) {
pageNo = 1;
}
if (pageNo > totalPage) {
pageNo = totalPage;
}
var form = document.getElementById("gridForm");
document.getElementById("pageNo").value = pageNo;
form.action = "showCheckCertsForPreCheck.do";
form.method = "post";
form.submit();
}
<!--框架右边列表-->
<div class="adon_list">
<h2>个体工商户验照信息列表:</h2>
<table id="gridbox"  style="width:99%" gridHeight="auto" imgpath="/IBS/js/dhtmlxGrid/imgs/" border="1" lightnavigation="true">
<tr>
<td type="ro" width="60">验照年份</td>
<td type="ro" width="150">字号</td>
<td type="ro" width="80">经营者姓名</td>
<td type="ro" width="100">注册号</td>
<td type="ro" width="80">提交时间</td>
<td type="ro" width="120">状态</td>
<td type="ro" width="127">操作</td>
</tr>

<c:set var="checkCertList" value="${pagination.elementList}" />
<c:forEach items="${checkCertList}" var="checkCert" varStatus="vs">
  <tr>
<td type="ro">${checkCert.fldYear}</td>
<td type="ro">${checkCert.fldStoreName}</td>
<td type="ro">${checkCert.fldManagerName}</td>
<td type="ro">${checkCert.fldRn}</td>
<td type="ro"><fmt:formatDate value="${checkCert.fldCommitTime}" pattern="yyyy-MM-dd"/></td>
<td type="ro">${applicationScope.checkCertStatusMap[checkCert.fldCheckState]}</td>
<td type="ro">
<a href="viewCheckCertsForPreCheckAction.do?certId=${checkCert.fldId}">预审</a>
<a href="viewCertAction_viewCert.do?certId=${checkCert.fldId}&sn=${checkCert.fldSn}">查看</a>
</td>
  </tr>
</c:forEach>
   </table>
</div>

<div class="list">
<s:form id="gridForm" name="gridForm" cssStyle="margin-bottom:0px;"
method="post" autoComplete="off">
<input type="hidden" name="pagination.currentPage" id="pageNo"
value="${pagination.currentPage}" />
<input type="hidden" name="pagination.totalPages"
value="${pagination.totalPages}" />
</s:form>

<c:if test="${!empty checkCertList}">
            第${pagination.currentPage}页, 共${pagination.totalPages}页
            <a href="javascript:jumpPage(1)">首页</a>
<a
href="javascript:jumpPage(${pagination.currentPage - 1}, ${pagination.totalPages})">上一页</a>
<a
href="javascript:jumpPage(${pagination.currentPage + 1}, ${pagination.totalPages})">下一页</a>
<a
href="javascript:jumpPage(<fmt:formatNumber type='number' value='${pagination.totalPages}'/>)">末页</a>
</c:if>
</div>
</div>
<!--框架右边内容结束-->



JSON格式的,下面是action里面的代码,后面是JSP页面的
// 生成JSON数据(为什么只能显示一行,难道屏蔽相同的ID)
  public String getJSON1() {
List<Integer> list = this.getList();
String json = "{rows:[";
for (int i = 0; i