这里只有一个表,表字段有group2id,group3id,userid,group2id为推荐人二级部门ID,group3id为推荐人三级部门ID,userid为推荐人ID,
有三个LIST,分别为ArrayList group2List=Manager.getInstance.getGroup2IdList();
ArrayList group3List =Manager.getInstance.getGroup2IdList(group2id);
ArrayList userList =Manager.getInstance.getGroup2IdList(group3id);
要展现成如图片那样,代码应该怎么写,或者什么思路,谢谢了,解决就给分!
有三个LIST,分别为ArrayList group2List=Manager.getInstance.getGroup2IdList();
ArrayList group3List =Manager.getInstance.getGroup2IdList(group2id);
ArrayList userList =Manager.getInstance.getGroup2IdList(group3id);
要展现成如图片那样,代码应该怎么写,或者什么思路,谢谢了,解决就给分!
这关系到输出的代码。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table width="619" height="418" border="1">
<tr>
<td width="198">二级</td>
<td width="118">三级</td>
<td width="102">推荐人</td>
<td width="82">后付款</td>
<td width="85">半年/全年卡</td>
</tr>
<tr>
<td rowspan="6"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td rowspan="2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>其他的自己填吧!
private void SpanRow(DataGrid dg,int col1,int col2,int col3,int row,int rownum)
{
int i,j;
int subrow = row;
for( i=row;i<rownum;i++ )
{
int intSpan=1;
string strA1=dg.Items[i].Cells[col1].Text.Trim();
string strA2=dg.Items[i].Cells[col2].Text.Trim();
string strA3=dg.Items[i].Cells[col3].Text.Trim();
for( j=i+1;j<rownum;j++)
{
string strB1=dg.Items[j].Cells[col1].Text.Trim();
string strB2=dg.Items[j].Cells[col2].Text.Trim();
string strB3=dg.Items[j].Cells[col3].Text.Trim();
if(strA1==strB1 && strA2==strB2 && strA3==strB3)
{
intSpan++; dg.Items[i].Cells[col1-1].RowSpan = intSpan;
dg.Items[i].Cells[col1-1].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col1-1].Visible = false;
dg.Items[i].Cells[col1].RowSpan = intSpan;
dg.Items[i].Cells[col1].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col1].Visible = false;
dg.Items[i].Cells[col2].RowSpan = intSpan;
dg.Items[i].Cells[col2].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col2].Visible = false;
dg.Items[i].Cells[col3].RowSpan = intSpan;
dg.Items[i].Cells[col3].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col3].Visible = false;
}
else
{
break;
}
} if( j>=rownum )
{
} i=j-1;
subrow=j;
}
}
#endregion
this.grdReqNum.DataSource = ds.Tables[SL_SetFactoryData.SL_SETFACTORY_TABLE];
this.grdReqNum.DataBind();
//----------------------------------------------
SpanRow(this.grdReqNum,2,3,4,0,this.grdReqNum.Items.Count);
//----------------------------------------------
private void SpanRow(DataGrid dg,int col1,int col2,int col3,int row,int rownum)
{
int i,j;
int subrow = row;
for( i=row;i<rownum;i++ )
{
int intSpan=1;
string strA1=dg.Items[i].Cells[col1].Text.Trim();
string strA2=dg.Items[i].Cells[col2].Text.Trim();
string strA3=dg.Items[i].Cells[col3].Text.Trim();
for( j=i+1;j<rownum;j++)
{
string strB1=dg.Items[j].Cells[col1].Text.Trim();
string strB2=dg.Items[j].Cells[col2].Text.Trim();
string strB3=dg.Items[j].Cells[col3].Text.Trim();
if(strA1==strB1 && strA2==strB2 && strA3==strB3)
{
intSpan++; dg.Items[i].Cells[col1-1].RowSpan = intSpan;
dg.Items[i].Cells[col1-1].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col1-1].Visible = false;
dg.Items[i].Cells[col1].RowSpan = intSpan;
dg.Items[i].Cells[col1].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col1].Visible = false;
dg.Items[i].Cells[col2].RowSpan = intSpan;
dg.Items[i].Cells[col2].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col2].Visible = false;
dg.Items[i].Cells[col3].RowSpan = intSpan;
dg.Items[i].Cells[col3].VerticalAlign=VerticalAlign.Middle;
dg.Items[j].Cells[col3].Visible = false;
}
else
{
break;
}
} if( j>=rownum )
{
} i=j-1;
subrow=j;
}
}
#endregion
this.grdReqNum.DataSource = ds.Tables[SL_SetFactoryData.SL_SETFACTORY_TABLE];
this.grdReqNum.DataBind();
//----------------------------------------------
SpanRow(this.grdReqNum,2,3,4,0,this.grdReqNum.Items.Count);
//----------------------------------------------
其它两个List是读取部门信息表的吧?首先:如果读取数据库代码是你写的话!
用join语句将用户表和部门表的数据一次性返回到一个List中.
这样你前面显示就很好处理.
<tr>
<td>2id</td>
<td>3id</td>
<td>uid</td>
</tr>
<%
ArrayList group2List=Manager.getInstance.getGroup2IdList();
for(int i = 0;i<group2List.size();i++)
{
String name_2 = (String)group2List.get(i);
%>
<tr>
<td>name_2</td>
<%
ArrayList group3List =Manager.getInstance.getGroup2IdList(group2id);
for(int j = 0;j<group3List.size();j++)
{
String name_3 = (String)group3List.get(j);
%>
<td>name_3</td>
<%
ArrayList userList =Manager.getInstance.getGroup2IdList(group3id);
for(int k = 0;k < userList.size();k++)
{
String uname = (String)userList.get(k);
%>
<td>uname</td>
<%
}
%>
<%
}
%>
</tr>
<%
}
%>
</table>
public class A(){//二级推荐人部门
//some properties
private List list;//B的集合
//get method for list
//set method for list
// other properties get method
// other properties set method
}public class B(){//三级推荐人部门
//some properties
private List list;//C的集合
//get method for list
//set method for list
// other properties get method
// other properties set method
}
public class C(){//人员
//some properties
private List list;
//get method for list
//set method for list
// other properties get method
// other properties set method
}
在页面上显示时,直接迭叠出来就行了。不知道楼主能否明白?