【问题标题】:Infragistics hidden column updateInfragistics 隐藏列更新
【发布时间】:2012-10-28 10:02:25
【问题描述】:

我在实体框架代码优先 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())

这是显示的内容:

现在让我们添加更新功能(我知道只读是无用的,因为我们不应该看到它):

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 列是可见的。

这发生在我添加更新功能时。您是否知道如何修复“添加新行”行,就像我的列是可见的一样?提前致谢。

【问题讨论】:

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


    【解决方案1】:

    我在我的 ID 列上使用 .Width("0px") 和 ReadOnly 让它工作。有点脏但没有别的选择……

    【讨论】:

      【解决方案2】:

      也许你应该添加这个

      }).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

      【讨论】:

      • 我也试过了,问题是用户可以根据需要切换列,而我不希望他这样做。
      • 奇怪,在上面链接的示例中,他们说This sample demonstrates how columns are hidden during grid initialization. In this example, “Product Name” and “List Price” columns are hidden in the grid and have allowHiding set to false. Note: When hiding columns during initialization, column indicators are not shown, so hidden columns cannot be made visible by the user.
      • 添加.AllowHiding(false) 解决了这个问题。我编辑了你的答案:)
      • 谢谢,那部分代码可能还在剪贴板中 :-)
      猜你喜欢
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-09
      相关资源
      最近更新 更多