Hi,
I am using igGrid in an Asp.net MVC3 project, this project supports multiple languages, that means I should set the column header text with global resources. I found that the columns I set to hidden is working fine in English, but not in other language like Norwegian, the hidden columns still display. Is anyone know what's the problem?
Hello Jason,
Do you use the hidden option of the column
column.For(x => x.Name).HeaderText(this.GetGlobalResourceObject("Grid", "PRODUCT_NAME").ToString()).Hidden(true);
or using the ColumnSetting
features.Hiding().ColumnSettings(settings => settings.ColumnSetting().ColumnKey("Name").Hidden(true).AllowHiding(true));
I tried to reproduce the issue with the online sample :
http://localhost:14991/samplesbrowser/grid/column-hiding-basic
I set the Product_Name resource in Norwegian (Bokmål) but I was not able to encounter the behavior.
Can you please share isolated code snippet ?
Hope hearing from you.
Hello Tsvetelina,
Thanks for your answer.
please see the code I am working,:
@(Html.Infragistics().Grid<Message>(Model.Object.Messages.Where(m => m.MessageBox == MessageBoxKind.Inbox))
.ID("igGridInboxList").PrimaryKey("MessageId")
.AutoGenerateColumns(false)
.LocalSchemaTransform(false)
.Columns(column =>
{
column.For(x => x.SenderName).DataType("string").HeaderText(@Resources.MessageList_From).Width("100px");
column.For(x => x.Subject).DataType("string").HeaderText(@Resources.MessageList_Subject).Width("340px");
column.For(x => x.SendTime).DataType("date").HeaderText(@Resources.MessageList_Time).Width("120px");
column.For(x => x.Tags).DataType("string").HeaderText(@Resources.MessageList_Tags).Width("120px");
column.For(x => x.Content).DataType("string").HeaderText(@Resources.MessageList_Content).Width("500px");
column.For(x => x.MessageId).DataType("int").HeaderText(@Resources.MessageList_MessageId).Width("100px");
})
.Features(features =>
features.RowSelectors().EnableCheckBoxes(true);
features.Paging().PageSize(10).PrevPageLabelText(@Resources.MessageList_Pre).NextPageLabelText(@Resources.MessageList_Next);
features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => settings.ColumnSetting().ColumnKey(@Resources.MessageList_From).AllowSorting(true));
features.Selection().MouseDragSelect(true).MultipleSelection(true).Mode(SelectionMode.Row);
features.Hiding().ColumnSettings(settings =>
settings.ColumnSetting().ColumnKey(@Resources.MessageList_Content).Hidden(true).AllowHiding(false);
settings.ColumnSetting().ColumnKey(@Resources.MessageList_MessageId).Hidden(true).AllowHiding(false);
});
.Width("100%")
.Height("100%")
.AutoGenerateLayouts(false)
.DataSourceUrl(Model.Object.UrlToGetPagingInboxData).DataBind()
.Render()
)
I checked the html, I found that the hidden columns still display if I set the language to Norwegian, do you know why?
Thank you for getting back to us.
I noticed that you are setting the ColumnKey using the resource string
ColumnKey(@Resources.MessageList_Content)
You should set the name of the field as ColumnKey, not the HeaderText
column.For(x => x.Content).DataType("string").HeaderText(@Resources.MessageList_Content).Width("500px"); column.For(x => x.MessageId).DataType("int").HeaderText(@Resources.MessageList_MessageId).Width("100px"); ...... settings.ColumnSetting().ColumnKey("Content").Hidden(true).AllowHiding(false); settings.ColumnSetting().ColumnKey("MessageId").Hidden(true).AllowHiding(false);
......
settings.ColumnSetting().ColumnKey("Content").Hidden(true).AllowHiding(false);
settings.ColumnSetting().ColumnKey("MessageId").Hidden(true).AllowHiding(false);
Hope this helps.
Hi Tsvetelina,
Thanks for your reply, you're right, I also found this problem. The problem has been solved by using the ColumnKey.