jqgrid列动态加载

private void InitGrid(string entityName)
{
Session["entityName"] = entityName;
ArrayList colInfoList = GetTableInfo(ListAndTableExtension.ConvertToTableColumnName(entityName));
if (colInfoList != null && colInfoList.Count > 0)
{
int i = 0;
foreach (dynamic c in colInfoList)
{
JQGridColumn col = new JQGridColumn();
col.DataField = ListAndTableExtension.ConvertToEntityColumnName(c.ColumnName);
col.HeaderText = c.Comments;
i++;
if (col.DataField != "Id")
jq2.Columns.Add(col);
}
JQGridColumn cc = new JQGridColumn();
cc.DataField = "Id";
cc.Frozen = true;
cc.PrimaryKey = true;
cc.Visible = true;
cc.HeaderText = "PK";
jq2.Columns.Insert(0, cc);

}
else
{
throw new Exception("表不存在或未定义任何列");
}
jq2.DataUrl = string.Format("/CCR/CcrFinancialIndexEdit.aspx?_method=searchCcrFinancialIndexList&entityName={0}",
entityName);
jq2.ComputHeight = string.Empty;
jq2.Height = 150;
jq2.Width = int.Parse((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width * 0.6).ToString().Split('.')[0]);
}

posted on 2015-12-24 15:50  听哥哥的话  阅读(486)  评论(0编辑  收藏  举报

导航