2012-11-08 47 views
3

我在实体框架代码优先的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列是可见的。

这件事发生的时候我加入了更新功能。你有什么想法,我可以如何解决“添加新行”行像我的列一样可见?提前致谢。

回答

4

也许你应该增加这个

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

+0

我tryied这个也行,问题是,如果他想用户可以切换栏,我不想他。 –

+0

奇怪的是,在上面链接的例子中,他们说'这个示例演示了在网格初始化时如何隐藏列。在此示例中,“产品名称”和“列表价格”列隐藏在网格中,并且allowHiding设置为false。注意:在初始化过程中隐藏列时,不显示列指示符,因此用户不能看到隐藏的列。' – Steve

+0

添加'.AllowHiding(false)'解决了问题。我编辑了你的答案:) –

0

我在我的ID栏上使用了.Width("0px")和ReadOnly。有点脏,但没有别的选择......