议:如何将树形菜单形式的数据转化成HTML的二维表(相同内容需合并单元格)
一般做OA类管理系统,经常涉及到“组织架构”的概念,那么像这种有上下层级关系的数据一般会做成树形菜单的方式显示,底层代码必定会用到递归算法。这篇随笔的目的就是要谈谈除了用树形菜单来显示这种上下层级关系的数据,还有其他的显示方式吗?答案是有的,例如即将要谈到的二维表显示方式,同时也是本随笔的核心内容。
首先来看二维表的显示效果图:
如果看到这里,你觉得这就是你想要的显示效果,或者对此比较感兴趣。请接着往下看的实现步骤:
1.取出所有的数据临时保存到DataTable中,即内存中,拼html时直接查DataTable中的数据,不用去反复读取数据库,提高效率;
2.根据节点编号获取该节点下所有的末端子节点编号,因为末端子节点的个数就决定了<table>的行数;
3.将查到的末端子节点编号的所有父节点编号也查出来,拼接起来,就知道了<table>的每行的列数;
4.对节点的编号进行排序,这样可以把每列下的相同行的节点编号集中在一起,方便后面的合并单元格;
5.遍历行和列,合并每列相同行的单元格;
6.最后一步,拼接空白的列。
如下是具体代码实现过程:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text; /// <summary>
///KpiTable 的摘要说明
/// </summary>
public class KpiTable
{
DBUtility.SQLHelper sqlhelper = new DBUtility.SQLHelper();
public string GetKpiTable(string kpino, string businessno, string tenderno)
{
//1.取出所有的数据临时保存到dt2,即内存中,拼html时直接查dt2中的数据,不用去反复读取数据库,提高效率
DataTable dt2 = new DataTable();
{
DataSet ds = new DataSet();
int i = sqlhelper.RunSQL(string.Format("select count(1) from sys.objects where name = 'KpiValue{0}'", businessno));
if (string.IsNullOrEmpty(tenderno) || i<)//如果有标段编号就要把KpiValueXXX表里的KpiValue1查出来显示
{
sqlhelper.RunSQL(string.Format(@"select KpiNo,KpiName,KpiInfo,ISNULL(KpiParentNo,0) KpiParentNo,KpiWeight,0 KpiValue1,'' KpiMethod,'' KpiSampleType,'' KpiRule,'' KpiCriterion,'' KpiAreaRule,'' KpiSampleRule from KpiTree{0}
union all select KpiNo,KpiName,KpiInfo,ISNULL(KpiParentNo,0) KpiParentNo,KpiWeight,0 KpiValue1,KpiMethod,KpiSampleType,KpiRule,KpiCriterion,KpiAreaRule,KpiSampleRule from Kpi{0}",businessno), ref ds);
}
else
{
sqlhelper.RunSQL(string.Format(@"select * from (
select KpiNo,KpiName,KpiInfo,ISNULL(KpiParentNo,0) KpiParentNo,KpiWeight,0 KpiValue1,'' KpiMethod,'' KpiSampleType,'' KpiRule,'' KpiCriterion,'' KpiAreaRule,'' KpiSampleRule from KpiTree{0}
union all select KpiNo,KpiName,KpiInfo,ISNULL(KpiParentNo,0) KpiParentNo,KpiWeight,0 KpiValue1,KpiMethod,KpiSampleType,KpiRule,KpiCriterion,KpiAreaRule,KpiSampleRule from Kpi{0}
) a left join KpiValue{0} b on a.kpino = b.kpino and TenderNo='{1}'", businessno, tenderno), ref ds);
}
dt2 = ds.Tables[];
}
//2.根据节点编号获取该节点下所有的末端子节点编号,因为末端子节点的个数就决定了table的行数
DataTable dt = new DataTable();
{
DataSet ds = new DataSet();
if (string.IsNullOrEmpty(kpino) || kpino == "")
{
sqlhelper.RunSQL(string.Format(@"select kpino from (select kpino from kpitree{0} union all select kpino from Kpi{0}) t where kpino not in (select isnull(KpiParentNo,0) from (select KpiParentNo from kpitree{0} union all select KpiParentNo from Kpi{0}) t)", businessno), ref ds);
}
else
{
string endKpiNo = RecursionEndKpiNo(dt2, kpino).Trim(',');
endKpiNo = endKpiNo == "" ? "" : endKpiNo;
string kpinos = string.Empty;
foreach (string str in endKpiNo.Split(',')) { kpinos += "'" + str + "',"; }
kpinos = kpinos.Trim(',');
sqlhelper.RunSQL(string.Format(@"select kpino from (select kpino from kpitree{0} union all select kpino from Kpi{0}) t where kpino not in (select isnull(KpiParentNo,0) from (select KpiParentNo from kpitree{0} union all select KpiParentNo from Kpi{0}) t) and kpino in ({1})", businessno, kpinos), ref ds);
}
dt = ds.Tables[];
}
//3.将查到的末端子节点编号的所有父节点编号也查出来,拼接起来,就知道了table的每行的列数
foreach (DataRow row in dt.Rows)
{
row["kpino"] = Recursion(dt2, row["kpino"]);
}
//4.对编号进行排序,这样可以把每列下的相同行的节点编号集中在一起,方便后面的合并单元格
var drArray = dt.Select("1=1", "kpino");
//5.限制输出kpino之前的父节点信息
foreach (DataRow row in drArray)
{
int index = row["kpino"].ToString().IndexOf(kpino);
if (index > -)
{
row["kpino"] = row["kpino"].ToString().Substring(index);
}
}
//6.遍历行和列
int maxCount = GetMaxCount(drArray);
StringBuilder sbJson = new StringBuilder();
for (int i = ; i < drArray.Length; i++)
{
DataRow row = drArray[i];
sbJson.Append("<tr>");
var kpinoArray = row["kpino"].ToString().Trim(',').Split(',');
int kpinoArrayLenth = kpinoArray.Length;
for (int j = ; j < kpinoArrayLenth; j++)
{
string str = kpinoArray[j];
if (str != "")
{
var dr = dt2.Select("kpino='" + str + "'");
//合并每列相同行的单元格
if (dr.Length > && !EqualUpColumnValue(i, j, drArray))
{
double kpiWeight = GetKpiWeight(dt2, str);
double kpiValue = GetKpiValue(dt2, str);
string kpiValueStr = string.IsNullOrEmpty(tenderno) ? "" : "[" + (kpiValue * kpiWeight).ToString("0.00") + "]";
string kpiDes = GetKpiDes(dt2, str);
sbJson.Append(string.Format("<td rowspan='{0}'>{1}({2}%){3}{4}</td>", GetColspan(i, j, drArray), dr[]["kpiname"], (kpiWeight * ).ToString("0.00"), kpiValueStr, kpiDes));
}
}
}
//拼接空白的列
for (int j = ; j < maxCount - kpinoArrayLenth; j++)
{
sbJson.Append("<td></td>");
}
sbJson.Append("</tr>");
}
return "<table id='kpitable' border='1px'>" + sbJson.ToString() + "</table>";
} private string RecursionEndKpiNo(DataTable dt, object parentId)
{
StringBuilder sbJson = new StringBuilder(); DataRow[] rows = dt.Select(string.Format("KpiParentNo = '" + parentId + "'"));
if (rows.Length > )
{
foreach (DataRow row in rows)
{
string str = RecursionEndKpiNo(dt, row["kpino"]);
sbJson.Append("" + row["kpino"] + "," + str);
}
}
return sbJson.ToString();
}
private bool IsChild(DataTable dt, string parentId)
{
DataRow[] rows = dt.Select(string.Format("KpiParentNo = '" + parentId + "'"));
if (rows.Length > )
{
return true;
}
else
{
return false;
}
} private string Recursion(DataTable dt, object parentId)
{
StringBuilder sbJson = new StringBuilder(); DataRow[] rows = dt.Select("kpino = '" + parentId + "'");
if (rows.Length > )
{
if (rows[]["KpiParentNo"].ToString() == "" || rows[]["KpiParentNo"].ToString() == "")
{
sbJson.Append("0,");
}
else
{
sbJson.Append(Recursion(dt, rows[]["KpiParentNo"]));
}
}
sbJson.Append(parentId.ToString() + ",");
return sbJson.ToString();
}
private int GetMaxCount(DataRow[] drArray)
{
int temp = ;
foreach (DataRow row in drArray)
{
int count = row["kpino"].ToString().Trim(',').Split(',').Length;
if (count > temp)
{
temp = count;
}
}
return temp;
}
private bool EqualUpColumnValue(int rowIndex, int colIndex, DataRow[] drArray)
{
if (rowIndex == )
{
return false;
} string[] kpinoArray = drArray[rowIndex - ]["kpino"].ToString().Trim(',').Split(',');
if (kpinoArray.Length > colIndex)
{
string upColumnValue = drArray[rowIndex]["kpino"].ToString().Trim(',').Split(',')[colIndex];
if (upColumnValue == kpinoArray[colIndex])
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
private int GetColspan(int rowIndex, int colIndex, DataRow[] drArray)
{
int colspan = ;
string[] kpinoArray = drArray[rowIndex]["kpino"].ToString().Trim(',').Split(','); while (rowIndex < drArray.Length - )
{
string[] kpinoArray2 = drArray[rowIndex + ]["kpino"].ToString().Trim(',').Split(',');
if (kpinoArray2.Length > colIndex)
{
if (kpinoArray[colIndex] == kpinoArray2[colIndex])
{
colspan++;
}
else
{
break;
}
}
else
{
break;
}
rowIndex++;
}
return colspan;
}
private double GetKpiWeight(DataTable dt, string kpino)
{
double kpiWeight = ;
var drArray = dt.Select("kpino='" + kpino + "'");
if (drArray.Length > )
{
string kpiParentNo = drArray[]["KpiParentNo"].ToString();
double kpino_KpiWeight = Convert.ToDouble(drArray[]["KpiWeight"]);
drArray = dt.Select("KpiParentNo='" + kpiParentNo + "'");
if (drArray.Length > )
{
double result = ;
foreach (DataRow row in drArray)
{
result += Convert.ToDouble(row["KpiWeight"]);
}
kpiWeight = (kpino_KpiWeight / result);
}
}
return kpiWeight;
}
private double GetKpiValue(DataTable dt, string kpino)
{
var drArray = dt.Select(string.Format("kpino='{0}'",kpino));
if (drArray.Length>)
{
return Convert.ToDouble(drArray[]["KpiValue1"]);
}
return ;
}
private string GetKpiDes(DataTable dt, string kpino)
{
string des = string.Empty;
var drArray = dt.Select(string.Format("kpino='{0}'",kpino));
if (drArray.Length>)
{
string KpiMethod = drArray[]["KpiMethod"].ToString();
string KpiSampleType = drArray[]["KpiSampleType"].ToString();
string KpiRule = drArray[]["KpiRule"].ToString();
string KpiCriterion = drArray[]["KpiCriterion"].ToString();
string KpiAreaRule = drArray[]["KpiAreaRule"].ToString();
string KpiSampleRule = drArray[]["KpiSampleRule"].ToString(); //表格样式
if (!string.IsNullOrEmpty(KpiMethod))
{
//des += "<table id='kpitabledes'>";
//des += "<tr><td>计算方法:</td><td>" + KpiMethod +"</td></tr>";
//des += "<tr><td>采样类别:</td><td>" + KpiSampleType + "</td></tr>";
//des += "<tr><td>评价标准:</td><td>" + KpiRule + "</td></tr>";
//des += "<tr><td>规范要点:</td><td>" + KpiCriterion + "</td></tr>";
//des += "<tr><td>测区规则:</td><td>" + KpiAreaRule + "</td></tr>";
//des += "<tr><td>测点规则:</td><td>" + KpiSampleRule + "</td></tr>";
//des += "</table>";
} //换行样式
//if (!string.IsNullOrEmpty(KpiMethod)) { des += "<br />计算方法:" + KpiMethod; }
//if (!string.IsNullOrEmpty(KpiSampleType)) { des += "<br />采样类别:" + KpiSampleType; }
//if (!string.IsNullOrEmpty(KpiRule)) { des += "<br />评价标准:" + KpiRule; }
//if (!string.IsNullOrEmpty(KpiCriterion)) { des += "<br />规范要点:" + KpiCriterion; }
//if (!string.IsNullOrEmpty(KpiAreaRule)) { des += "<br />测区规则:" + KpiAreaRule; }
//if (!string.IsNullOrEmpty(KpiSampleRule)) { des += "<br />测点规则:" + KpiSampleRule; }
}
return des;
} }
以及需要用到的表(sql脚本):
USE [Evaluation]
GO
/****** Object: Table [dbo].[Kpi] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Kpi](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](100) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiRule] [nvarchar](100) NULL,
[KpiCriterion] [nvarchar](100) NULL,
[KpiAreaRule] [nvarchar](100) NULL,
[KpiSampleRule] [nvarchar](100) NULL,
[KpiAreaNum] [int] NOT NULL,
[KpiSampleNum] [int] NOT NULL,
[KpiMinValue] [decimal](18, 2) NULL,
[KpiMaxValue] [decimal](18, 2) NULL,
[KpiOffset] [decimal](18, 2) NULL,
[KpiReferenceVal] [decimal](18, 2) NULL,
[KpiValueType] [nvarchar](50) NULL,
[KpiFormula] [nvarchar](50) NULL,
[KpiFormulaRule] [nvarchar](100) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiGoodMinValue] [decimal](18, 2) NULL,
[KpiGoodMaxValue] [decimal](18, 2) NULL,
[KpiGoodMethod] [nvarchar](50) NULL,
[KpiGoodOffset] [decimal](18, 2) NULL,
[KpiSampleType] [nvarchar](50) NULL,
[IsDLT] [smallint] NULL,
[CrtDate] [datetime] NULL,
[CrtUser] [nvarchar](50) NULL,
[UpdDate] [datetime] NULL,
[UpdUser] [nvarchar](50) NULL,
CONSTRAINT [PK_EVKpiInfo] PRIMARY KEY CLUSTERED
(
[KpiNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] GO
/****** Object: Table [dbo].[kpi1447055501128] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[kpi1447055501128](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](100) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiRule] [nvarchar](100) NULL,
[KpiCriterion] [nvarchar](100) NULL,
[KpiAreaRule] [nvarchar](100) NULL,
[KpiSampleRule] [nvarchar](100) NULL,
[KpiAreaNum] [int] NOT NULL,
[KpiSampleNum] [int] NOT NULL,
[KpiMinValue] [decimal](18, 2) NULL,
[KpiMaxValue] [decimal](18, 2) NULL,
[KpiOffset] [decimal](18, 2) NULL,
[KpiReferenceVal] [decimal](18, 2) NULL,
[KpiValueType] [nvarchar](50) NULL,
[KpiFormula] [nvarchar](50) NULL,
[KpiFormulaRule] [nvarchar](100) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiGoodMinValue] [decimal](18, 2) NULL,
[KpiGoodMaxValue] [decimal](18, 2) NULL,
[KpiGoodMethod] [nvarchar](50) NULL,
[KpiGoodOffset] [decimal](18, 2) NULL,
[KpiSampleType] [nvarchar](50) NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[kpi20150002] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[kpi20150002](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](100) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiRule] [nvarchar](100) NULL,
[KpiCriterion] [nvarchar](100) NULL,
[KpiAreaRule] [nvarchar](100) NULL,
[KpiSampleRule] [nvarchar](100) NULL,
[KpiAreaNum] [int] NOT NULL,
[KpiSampleNum] [int] NOT NULL,
[KpiMinValue] [decimal](18, 2) NULL,
[KpiMaxValue] [decimal](18, 2) NULL,
[KpiOffset] [decimal](18, 2) NULL,
[KpiReferenceVal] [decimal](18, 2) NULL,
[KpiValueType] [nvarchar](50) NULL,
[KpiFormula] [nvarchar](50) NULL,
[KpiFormulaRule] [nvarchar](100) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiGoodMinValue] [decimal](18, 2) NULL,
[KpiGoodMaxValue] [decimal](18, 2) NULL,
[KpiGoodMethod] [nvarchar](50) NULL,
[KpiGoodOffset] [decimal](18, 2) NULL,
[KpiSampleType] [nvarchar](50) NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[KpiTree] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KpiTree](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](50) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiCollectMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiIndex] [int] NULL,
[IsDLT] [smallint] NULL,
[CrtDate] [datetime] NULL,
[CrtUser] [nvarchar](50) NULL,
[UpdDate] [datetime] NULL,
[UpdUser] [nvarchar](50) NULL,
CONSTRAINT [PK_KpiTree] PRIMARY KEY CLUSTERED
(
[KpiNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] GO
/****** Object: Table [dbo].[kpitree1447055501128] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[kpitree1447055501128](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](50) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiCollectMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiIndex] [int] NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[KpiTree20150002] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KpiTree20150002](
[KpiNo] [nvarchar](50) NOT NULL,
[KpiName] [nvarchar](50) NULL,
[KpiInfo] [nvarchar](50) NULL,
[KpiParentNo] [nvarchar](50) NULL,
[KpiCollectMethod] [nvarchar](50) NULL,
[KpiWeight] [decimal](18, 2) NULL,
[KpiMemo] [nvarchar](100) NULL,
[KpiIndex] [int] NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[KpiValue] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KpiValue](
[TenderNo] [nvarchar](50) NOT NULL,
[KpiNo] [nvarchar](50) NOT NULL,
[KpiValue1] [decimal](18, 2) NULL,
[KpiValue2] [decimal](18, 2) NULL,
[SampleNumAll] [int] NULL,
[SampleNum1] [int] NULL,
[SampleNum2] [int] NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[KpiValue1447055501128] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KpiValue1447055501128](
[TenderNo] [nvarchar](50) NOT NULL,
[KpiNo] [nvarchar](50) NOT NULL,
[KpiValue1] [decimal](18, 2) NULL,
[KpiValue2] [decimal](18, 2) NULL,
[SampleNumAll] [int] NULL,
[SampleNum1] [int] NULL,
[SampleNum2] [int] NULL
) ON [PRIMARY] GO
/****** Object: Table [dbo].[KpiValue20150002] Script Date: 2016/3/25 16:06:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KpiValue20150002](
[TenderNo] [nvarchar](50) NOT NULL,
[KpiNo] [nvarchar](50) NOT NULL,
[KpiValue1] [decimal](18, 2) NULL,
[KpiValue2] [decimal](18, 2) NULL,
[SampleNumAll] [int] NULL,
[SampleNum1] [int] NULL,
[SampleNum2] [int] NULL
) ON [PRIMARY] GO
ALTER TABLE [dbo].[Kpi] ADD CONSTRAINT [DF_Kpi_KpiWeight] DEFAULT ((1)) FOR [KpiWeight]
GO
ALTER TABLE [dbo].[Kpi] ADD CONSTRAINT [DF_Kpi_KpiAreaNum] DEFAULT ((2)) FOR [KpiAreaNum]
GO
ALTER TABLE [dbo].[Kpi] ADD CONSTRAINT [DF_Kpi_KpiSampleNum] DEFAULT ((10)) FOR [KpiSampleNum]
GO
ALTER TABLE [dbo].[Kpi] ADD CONSTRAINT [DF_Kpi_IsDLT] DEFAULT ((0)) FOR [IsDLT]
GO
ALTER TABLE [dbo].[kpi20150002] ADD CONSTRAINT [DF_kpi20150002_KpiWeight] DEFAULT ((1)) FOR [KpiWeight]
GO
ALTER TABLE [dbo].[KpiTree] ADD CONSTRAINT [DF_KpiTree_KpiWeight] DEFAULT ((1)) FOR [KpiWeight]
GO
ALTER TABLE [dbo].[KpiTree] ADD CONSTRAINT [DF_KpiTree_IsDLT] DEFAULT ((0)) FOR [IsDLT]
GO
ALTER TABLE [dbo].[KpiTree20150002] ADD CONSTRAINT [DF_KpiTree20150002_KpiWeight] DEFAULT ((1)) FOR [KpiWeight]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指标编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指标名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级指标编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiParentNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权重' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiWeight'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上级指标编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiRule'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权重' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi', @level2type=N'COLUMN',@level2name=N'KpiCriterion'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指标配置表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Kpi'
GO
议:如何将树形菜单形式的数据转化成HTML的二维表(相同内容需合并单元格)的更多相关文章
- Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行
Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行 模版格式,图格式是最简单的格式,但实际效果不是这种,实际效果图如图2 图2 ,注意看红色部分,一对一是正常的,但是有一对多的订单 ...
- layui:数据表格如何合并单元格
layui.use('table', function () { var table = layui.table; table.render({ elem: '#applyTab' , url: '$ ...
- 雷林鹏分享:jQuery EasyUI 数据网格 - 合并单元格
jQuery EasyUI 数据网格 - 合并单元格 数据网格(datagrid)经常需要合并一些单元格.本教程将向您展示如何在数据网格(datagrid)中合并单元格. 为了合并数据网格(datag ...
- js动态加载数据并合并单元格
js动态加载数据合并单元格, 代码如下所示,可复制直接运行: <!DOCTYPE HTML> <html lang="en-US"> <head> ...
- .Net用字符串拼接实现表格数据相同时合并单元格
前言 最近在做项目通过GridView或Repeater绑定数据,如果两行或若干行某列值相同,需要进行合并单元格,但是实现过程中想到了字符串拼接,于是就没用绑定数据控件,而是用了html结合字符串实现 ...
- [办公应用]如何将excel合并单元格分拆后每个单元格上仍保留数据?
合并单元格虽然美观,但是无法进行排序.筛选等操作. 只有合并单元格拆分后才可以按常规进行统计.但是普通拆分后,excel仅保留合并单元格数据到区域左上角的单元格. 解决方案:选定多个合并单元格,应用本 ...
- php 数据导出到excel 2种带有合并单元格的导出
具体业务层面 可能会有所不同.以下两种方式涉及的合并单元格地方有所不同,不过基本思路是一致的. 第一种是非插件版本.可能更容易理解点,基本思路就是 组装table 然后 读取 输出到excel上.缺点 ...
- 数据可视化之PowerQuery篇(四)二维表转一维表,看这篇文章就够了
https://zhuanlan.zhihu.com/p/69187094 数据分析的源数据应该是规范的,而规范的其中一个标准就是数据源应该是一维表,它会让之后的数据分析工作变得简单高效. 在之前的文 ...
- 【Excle数据透视表】如何在数据透视表中使用合并单元格标志
先有数据透视表如下: 现在看着这个格式不舒服,我们希望调整成如下这种样式 步骤 单击数据透视表任意单元格→右键→数据透视表选项→布局和格式→合并且居中排列带标签的单元格 注意:如果数据透视表报表布局不 ...
随机推荐
- Java正则表达式--网页爬虫
网页爬虫:其实就一个程序用于在互联网中获取符合指定规则的数据 爬取邮箱地址,爬取的源不同,本地爬取或者是网络爬取 (1)爬取本地数据: public static List<String> ...
- nyoj 60 谁获得了最高奖学金
谁获得了最高奖学金 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同: ...
- [C语言 - 12] Union联合
union Student { int age; char *name; } stu; union只按照最长的数据成员分配控件,适用于有N个数据不会同时出现的情况,用以压缩空间.
- [置顶] 解成电OJ1003真实的谎言的记录
原题目 Description N个人做一个游戏,游戏中每个人说了一句话(可能是真的也可能是假的) 第i个人说:“N个人中有至少有ai个,至多有bi个人说的是真话!”(i = 1, 2, 3….. ...
- 3.x的触摸响应机制
第一种是采用函数回调,主要是用于MenuItem [cpp] view plaincopy // a selector callback void menuCloseCallback(Object* ...
- CSDN首页> 移动开发 直接拿来用!最火的Android开源项目(完结篇)
此前,CSDN移动频道推出的GitHub平台上“最受欢迎的开源项目”系列文章引发了许多读者的热议,在“直接拿来用!最火的Android开源项目”系列文章(一).(二)中,我们也相继盘点了40个GitH ...
- MSSQL 如何实现 MySQL 的 limit 查询方式 (转)
不知为何,MSSQL 中没有 limit 这个极为重要的查询方式,熟悉 MySQL 的朋友都知道,MySQL 的 limit 对于实现分页和一些限制结果集的应用中非常方便.没有不要紧,我们可以用其他方 ...
- C#double转化成字符串 保留小数位数, 不以科学计数法的形式出现
在C#中大家都会遇到这种情况 double类型的数据,需要格式化(保留N未有效数字)或者是保留N为小数等情况,我们往往采取double.tostring("参数");的方法.下 ...
- jquery回车提交表单
jquery回车提交表单,比较方便的功能. 三个事件keydown,keypress,keyup,分别是按下,按着没上抬,上抬键盘 ,所以用keyup. $(document).keyup(funct ...
- [Sciter系列] MFC下的Sciter–1.创建工程框架
Sciter SDK中提供的Win32下例程很多,唯独使用很多(对我个人而言)的MFC框架下Sciter程序的构建讲的很少,虽然MFC有这样那样的诟病,但是不可否认的是编写一般的小项目,这仍然是大 ...