C#中代码
[AjaxPro.AjaxMethod]
public static List<LxMerge> GetMerges(string strDateCode)
{
List<LxMerge> MergeList = new List<LxMerge>();
string sql = "";
sql = "select CRI.gId as gId,RI.cRptItemCode as RptItemCode,RI.cRptItemName as RptItemName,RI.cItemUnit as ItemUnit,CRI.cWgName as cWgName,CRI.cLjxName as cLjxName,CRI.cName as cName,CRI.iLocateNum as iLocateNum,"
+ "CRI.iRepairNum as iRepairNum,CRI.gId as LocatePics,CRI.gId as RepairPics,CRI.gId as PicHandle,CRI.gId as Handle "
+ " from CityWeekReport CWR inner join CityReportItem CRI on CWR.cDateCode=CRI.cDateCode and CWR.cSbrDeptCode=CRI.cSbrDeptCode "
+ " inner join ReportItem RI on CRI.cRptItemCode=RI.cRptItemCode where CWR.cDateCode='" + Sql.Format(strDateCode) + "' order by RptItemCode";
using (DataTable data = Sql.ExecuteDataset(CommandType.Text, sql).Tables[0])
{
string strPrevText = "";
int intIndex = 0;
int RowSpan =1;
for (int i = 0; i < data.Rows.Count; i++)
{
string strText = data.Rows[i]["RptItemName"].ToString();
if (strText != strPrevText)
{
if (RowSpan > 1)
{
LxMerge Merge = new LxMerge();
Merge.index = intIndex;
Merge.rowspan = RowSpan;
MergeList.Add(Merge);
}
intIndex = i;
RowSpan = 1;
}
else
{
RowSpan++;
}
strPrevText = strText;
}
if (data.Rows.Count > 0 && RowSpan > 1) //
{
LxMerge LastMerge = new LxMerge();
LastMerge.index =intIndex;
LastMerge.rowspan =RowSpan;
MergeList.Add(LastMerge);
}
}
return MergeList;
}
js中
onLoadSuccess加加载的时候应用
onLoadSuccess: function () {
var result = a_AjaxFun.GetMerges(m_DateCode);
if (result.error) {
alert(result.error.Message);
return;
}
var merges = result.value;
for (var i = 0; i < merges.length; i++)
$("#tabMain").datagrid('mergeCells', {
index: merges[i].index,
field: merges[i].field ,
rowspan: merges[i].rowspan
}); }