Hello,
I have created a iggrid. (jquery) (with columns and one primary key because I want to do update operations)
I get the following exception when I try to remove an item in the grid "In order to support update operations after a row was deleted, application should define "primaryKey" in options of igGrid."
I have defined a primary key and the primary key is in my object.When I add my primary key as first column visible in my grid it works. Ofcourse I don't want to show my primary key to the user.
Is they're a way to avoid this?
Example code:@(Html.Infragistics() .Grid(Model) .ID("grid1") .PrimaryKey("Id") .UpdateUrl("EditingConversieCodes") .AutoGenerateColumns(false) //.RenderCheckboxes(true) .Columns(column => { //column.For(x => x.Id).HeaderText("Id").DataType("number"); column.For(x => x.SourceCode).HeaderText("Source Code"); column.For(x => x.SourceDesc).HeaderText("Source Description"); column.For(x => x.TargetCode).HeaderText("Target Code"); column.For(x => x.TargetDescription).HeaderText("Target Desc"); }) .AutoCommit(true) .Features(features => { features.Filtering().Type(OpType.Local); features.Paging().PageSize(10).Type(OpType.Remote); features.Selection().Mode(SelectionMode.Row).MultipleSelection(true); features.RowSelectors(); features.Tooltips().Visibility(TooltipsVisibility.Always); features.Updating().EnableAddRow(true) .ColumnSettings(settings => { //settings.ColumnSetting().ColumnKey("Id").ReadOnly(true); settings.ColumnSetting().ColumnKey("Source_Code").EditorType(ColumnEditorType.Text); settings.ColumnSetting().ColumnKey("Source_Desc").EditorType(ColumnEditorType.Text); settings.ColumnSetting().ColumnKey("Target_Code").EditorType(ColumnEditorType.Text); settings.ColumnSetting().ColumnKey("Target_Desc").EditorType(ColumnEditorType.Text); }); }) .DataSourceUrl(Url.Action("DemoGrid")) .DataBind().Height("360px").Width("700px").Render())
My class: public class ConversieCode { public Int32 Id { get; set; } public string CountryCode { get; set; } public string CompanyCode { get; set; } public string TypeId { get; set; } public string SourceCode { get; set; } public string SourceDesc { get; set; } public string TargetCode { get; set; } public string TargetDescription { get; set; }}
Hello Tom,
Thank you for posting in the community.
Try to hide the Id column using the following column configuration:
column.For(x => x.Id).HeaderText("Id").DataType("number").Hidden(true);
Hope this helps,
Martin Pavlov
Infragistics, Inc.
support@infragistics.com
Hello Martin,
Thanks for your reply.
I have done this already and idd that works. But than I have another issue. I can't click anymore at the "x" (to remove a record) at the right. You see a gap between the x and my last column. (target des in this case)
But I think that we have to find the real problem and this is a little bit a work around. Do you or another person have another idea?
Yours faithfully,Tom Van de Putte