Reputation: 476
I'm using Infragistics on an Entity Framework code-first MVC project. I want to display a table with a hidden column (the ID) and it has to be editable. Here is what I've got so far:
<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())
This is what is displayed:
Now lets add the update feature (i know the readOnly is useless since we are not supposed to see it):
feature.Updating().EnableAddRow(true).EnableDeleteRow(true).EditMode(GridEditMode.Row).ColumnSettings(settings =>
settings.ColumnSetting().ColumnKey("TestId").ReadOnly(true)
);
And hide my ID-column:
column.For(x => x.TestId).DataType("int").HeaderText("id").Hidden(true);
Here is what i get. As you can see the table acts like my ID-column was visible.
This happened when I added the update feature. Do you have any idea on how I could fix the "Add new row" row acting like my column was visible? Thanks in advance.
Upvotes: 3
Views: 2139
Reputation: 216313
Probably you should add this
}).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
Upvotes: 4
Reputation: 476
I got it to work using .Width("0px")
and ReadOnly on my ID-column. A bit dirty but had no other choice...
Upvotes: 0