我在實體框架代碼優先的MVC項目上使用Infragistics。我想顯示一個隱藏列(ID)的表格,它必須是可編輯的。以下是我到目前爲止有:Infragistics隱藏列更新
<table id="igTests"></table>
@(Html.Infragistics().Grid<BusinessModel.VO.TestVO>().ID("igTests")
.AutoGenerateColumns(false)
.Columns(column =>
{
column.For(x => x.TestId).DataType("int").HeaderText("id");
column.For(x => x.TestNum).DataType("int").HeaderText("Test num");
column.For(x => x.Type).DataType("string").HeaderText("Type");
column.For(x => x.Nature).DataType("string").HeaderText("Nature");
column.For(x => x.TeamName).DataType("string").HeaderText("Team");
column.For(x => x.CreateDate).DataType("date").HeaderText("Creation date");
})
.Features(feature => {
feature.Sorting().CaseSensitive(true);
feature.Filtering().Mode(FilterMode.Simple);
})
.PrimaryKey("TestId")
.DataSource(Model.TestsVO.AsQueryable())
.DataBind()
.Render())
這是顯示的內容:
現在讓我們添加更新功能(我知道只讀是無用的,因爲我們不應該看它):
feature.Updating().EnableAddRow(true).EnableDeleteRow(true).EditMode(GridEditMode.Row).ColumnSettings(settings =>
settings.ColumnSetting().ColumnKey("TestId").ReadOnly(true)
);
和隱藏,我的ID列:
column.For(x => x.TestId).DataType("int").HeaderText("id").Hidden(true);
她e是我得到的。正如你所看到的,表格就像我的ID列是可見的。
這件事發生的時候我加入了更新功能。你有什麼想法,我可以如何解決「添加新行」行像我的列一樣可見?提前致謝。
我tryied這個也行,問題是,如果他想用戶可以切換欄,我不想他。 –
奇怪的是,在上面鏈接的例子中,他們說'這個示例演示了在網格初始化時如何隱藏列。在此示例中,「產品名稱」和「列表價格」列隱藏在網格中,並且allowHiding設置爲false。注意:在初始化過程中隱藏列時,不顯示列指示符,因此用戶不能看到隱藏的列。' – Steve
添加'.AllowHiding(false)'解決了問題。我編輯了你的答案:) –