1,在今天整理代码的时候,发现原来的一段代码,前台合并单元格。
需要在后端,原来的列表基础上,再增加一层。
- List<CASEListVO> list2 = super.doFind(hql.toString(), params.toArray(), currPage, pageSize);
- ArrayList<List<CASEListVO>> linkedList = new ArrayList<List<CASEListVO>>();
- List<String> keyList = new ArrayList<String>();
- for (CASEListVO vo : list2)
- {
- String key = vo.getItemCode();
- List<CASEListVO> tempList = new ArrayList<CASEListVO>();
- if (keyList.indexOf(key) == -1)
- {
- keyList.add(key);
- }
- else
- {
- continue;
- }
- for (CASEListVO vo1 : list2)
- {
- if (vo1.getItemCode().endsWith(key))
- {
- tempList.add(vo1);
- }
- }
- linkedList.add(tempList);
- }
- page.setList(linkedList);
List<CASEListVO> list2 = super.doFind(hql.toString(), params.toArray(), currPage, pageSize);
ArrayList<List<CASEListVO>> linkedList = new ArrayList<List<CASEListVO>>();
List<String> keyList = new ArrayList<String>();
for (CASEListVO vo : list2)
{
String key = vo.getItemCode();
List<CASEListVO> tempList = new ArrayList<CASEListVO>();
if (keyList.indexOf(key) == -1)
{
keyList.add(key);
}
else
{
continue;
}
for (CASEListVO vo1 : list2)
{
if (vo1.getItemCode().endsWith(key))
{
tempList.add(vo1);
}
}
linkedList.add(tempList);
}
page.setList(linkedList);//返回的列表
页面上操作,struts2
- <s:iterator value="page" id="list">
- <c:forEach var="recordList" items="${list}" varStatus="varStatus">
- <c:forEach var="record" items="${recordList}" varStatus="status">
- <tr>
- <td>
- <input name="selectIds" type="checkbox" value="${record.ltVo.listTmpId}"
- oldValue="${record.estTmpId }" />
- </td>
- ${status.index }--
- <%=((List) pageContext.getAttribute("recordList")).size()%>
- <c:if test="${status.index eq 0}">
- <td rowspan="<%=((List) pageContext.getAttribute("recordList")).size()%>" style="width: 240px;text-align: center;">
- ${record.listName}
- </td>
- </c:if>
- <td style="text-align: center;width:200px;">
- ${record.itemCode}
- </td>
- <td style="text-align: center;width: 200px;">
- ${record.projectName}
- </td>
- <td style="text-align: right;width: 200px">
- <fmt:formatNumber value="${record.rate}" pattern="##0.00" />
- </td>
- </tr>
- </c:forEach>
- </c:forEach>
- </s:iterator>
<s:iterator value="page" id="list">
<c:forEach var="recordList" items="${list}" varStatus="varStatus">
<c:forEach var="record" items="${recordList}" varStatus="status">
<tr>
<td>
<input name="selectIds" type="checkbox" value="${record.ltVo.listTmpId}"
oldValue="${record.estTmpId }" />
</td>
${status.index }--
<%=((List) pageContext.getAttribute("recordList")).size()%>
<c:if test="${status.index eq 0}">
<td rowspan="<%=((List) pageContext.getAttribute("recordList")).size()%>" style="width: 240px;text-align: center;">
${record.listName}
</td>
</c:if>
<td style="text-align: center;width:200px;">
${record.itemCode}
</td>
<td style="text-align: center;width: 200px;">
${record.projectName}
</td>
<td style="text-align: right;width: 200px">
<fmt:formatNumber value="${record.rate}" pattern="##0.00" />
</td>
</tr>
</c:forEach>
</c:forEach>
</s:iterator>
这样根据code在页面上就会显示分组合并单元格的效果。