Im trying to create a master / detail create page in mvc 5
at the top I have normal text input fields
at the buttom I have a grid
when I post back the data I entered in the grid is not there
the model look like this
public Bestiller bestilleren { get; set; }public IQueryable<Kontaktperson> kontaktpersoner { get; set; }
and the grid :
@(Html.Infragistics().Grid(Model.kontaktpersoner).PrimaryKey("ID").ID("grdKontaktpersoner").ShowHeader(true).Columns(column =>{column.For(m => m.ID).Hidden(true);column.For(m => m.Navn).HeaderText("Navn").Width("200px");column.For(m => m.E_Mail).HeaderText("Email").Width("200px");column.For(m => m.Tlfnr).HeaderText("Telefonnr.").Width("80px");column.For(m => m.RefNr).HeaderText("Ref. Nr.").Width("100px");}).Features(feature =>{feature.Updating().ColumnSettings(cs =>{cs.ColumnSetting().ColumnKey("ID").ReadOnly(true);cs.ColumnSetting().ColumnKey("Navn").EditorType(ColumnEditorType.Text).Required(true).TextEditorOptions(o => o.ValidatorOptions(vo => vo.MaxLength(50)));cs.ColumnSetting().ColumnKey("E_Mail").EditorType(ColumnEditorType.Text).TextEditorOptions(o => .ValidatorOptions(vo => vo.MaxLength(60)));cs.ColumnSetting().ColumnKey("Tlfnr").EditorType(ColumnEditorType.Text).TextEditorOptions(o => o.ValidatorOptionsvo => vo.MaxLength(20)));cs.ColumnSetting().ColumnKey("RefNr").EditorType(ColumnEditorType.Text).TextEditorOptions(o => o.ValidatorOptionsvo => vo.MaxLength(30)));}).CancelLabel("Afbryd").AddRowLabel("Tilføj kontaktperson").DeleteRowTooltip("Slet kontaktperson").DoneLabel("Gem").EditMode(GridEditMode.Row).EnableDeleteRow(true);}).AutoGenerateColumns(false).AutoAdjustHeight(true).AutoCommit(true).Width("100%").DataSource(Model.kontaktpersoner).DataBind().Render())
I use 2014.1 sr 2249
Hi Christian,
Can you take my example (attached to this thread) and update it to reflect your scenario? Then send it back to me. It will be helpful to have a small running example of your scenario that I can use as part of my research into this matter.
Thanks!
This is a create page meaning that both Bestiller and Kontaktpersoner are empty
I cant update data to the server on Kontaktperson when the foreign key Bestiller_ID is empty
I see you have the DataSource() set but I believe you probably want to set the DataSourceURL instead. Also I don't see where you are setting the UpdateUrl. You will need this set to the UpdateUrl so the controller can update the model.
I have attached an example you can reference. Here within you will see:
@(Html.Infragistics()
.Grid<MvcApplication1.Models.Wine>()
.ID("grid1")
.AutoGenerateLayouts(false)
.Columns(column =>
{
column.For(x => x.WineID).HeaderText("ID").DataType("number");
column.For(x => x.ProductName).HeaderText("ProductName").DataType("string");
column.For(x => x.Region).HeaderText("Region").DataType("string");
column.For(x => x.VintageYear).DataType("date").HeaderText("Vintage Year");
column.For(x => x.CategoryID).DataType("int").HeaderText("Category ID");
column.For(x => x.AverageUnitPricePerBottle).DataType("decimal").HeaderText("Avg Price");
column.For(x => x.RecommendToFriend).DataType("bool").HeaderText("Recommend Wine");
column.For(x => x.TroyRating).DataType("int").HeaderText("TroyRating");
})
.Width("800px")
.Height("500px")
.PrimaryKey("WineID")
.Features(features =>
features.Sorting().Type(OpType.Local).ColumnSettings(settings =>
settings.ColumnSetting().ColumnKey("WineID").CurrentSortDirection("ascending");
});
features.Selection().Mode(SelectionMode.Row).MultipleSelection(true).Activation(true);
features.Paging().Type(OpType.Local).PageSize(5);
features.Updating().EditMode(GridEditMode.Row).ColumnSettings(cs =>
cs.ColumnSetting().ColumnKey("WineID").ReadOnly(false);
cs.ColumnSetting().ColumnKey("VintageYear").EditorType(ColumnEditorType.DatePicker);
.DataSourceUrl(Url.Action("GetGridData", "Home"))
.UpdateUrl(Url.Action("UpdateGrid", "Home"))
.DataBind()
.Render())
Then take a look at what I am doing in my controller.
Let me know if you have any additional questions related to this inquiry. Thanks Christian!