Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2715
iggrid model empty on postback
posted

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.ValidatorOptions
vo => vo.MaxLength(20)));
cs.ColumnSetting().ColumnKey("RefNr").EditorType(ColumnEditorType.Text).TextEditorOptions(o => o.ValidatorOptions
vo => 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

  • 10240
    posted

    Hi Christian,

    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!

     

     

    igGrid_MVC4_WineList_Updating.zip