asp.net-mvc - Infragistics 隐藏列更新

标签 asp.net-mvc razor infragistics ignite-ui iggrid

我在 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/

相关文章:

asp.net-core - &lt;textarea&gt; 与 "asp-for="一起时不显示内部文本

wpf - 确定 xamDataGrid 上的筛选器状态

c# - 首先使用实体​​框架代码与 nosql 数据库

asp.net-mvc - 验证包含嵌套域对象的 Viewmodel

jquery - 复制 stackoverflow 问题页面中使用的标签文本框的最简单方法是什么

asp.net-mvc - 有没有办法使用 asp.net mvc Razor ViewEngine 使 @section 成为可选?

html - 在 MVC 中水平居中此 Bootstrap 表单的正确方法是什么?

c# - MVC 5 详细信息 View 不显示具有外键的字段的数据

c# - 基础设施网格选择

javascript - 获取隐藏的 igGrid 列的单元格值