我在 Entity Framework 代码优先 MVC 项目上使用 Infragistics。我想显示一个带有隐藏列(ID)的表,并且它必须是可编辑的。这是我到目前为止所得到的:
<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())
这是显示的内容:
现在让我们添加更新功能(我知道 readOnly 没用,因为我们不应该看到它):
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);
这是我得到的。如您所见,表格就像我的 ID 列可见一样。
这发生在我添加更新功能时。您是否知道如何修复“添加新行”行就像我的列可见一样?提前致谢。
最佳答案
也许你应该添加这个
}).Features(features => features.Hiding()
.ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey("id").Hidden(true).AllowHiding(false)
http://www.infragistics.com/products/jquery/sample/grid/column-hiding-on-initialization
关于asp.net-mvc - Infragistics 隐藏列更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13285125/