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
380
MVC and DataSource
posted

I think I'm missing something...

I have a MVC app which is basically a form with an embedded grid control.

The View has a Model which is an object with a bunch of properties including a IQueryable Items list

I bind the DataSource property of the grid to Model.Items and everything displays just fine

However, when I submit the form back to the controller for processing the Items property of my object is always null?

What am I doing wrong, I have AutoCommit=true, I would have expected that to update the Items collection locally then on submitt the data would be returned

                        <!-- Items -->
                        @( Html.Infragistics().Grid<Purchasing.Models.PurchaseOrderItem>()
                               .AutoGenerateColumns(false)
                               .AutoCommit(true)
                               .ID("PurchaseOrder_Grid")
                               .Columns(column =>
                               {
                                   column.For(x => x.jobId).DataType("string").HeaderText("Job").Width("100");
                                   column.For(x => x.quantity).DataType("number").HeaderText("Quantity").Width("100");
                                   column.For(x => x.uom).DataType("string").HeaderText("Units").Width("100");
                                   column.For(x => x.item).DataType("string").HeaderText("Item").Width("300*");
                                   column.For(x => x.glAcct).DataType("string").HeaderText("GL Account").Width("300");
                                   column.For(x => x.id).Hidden(true);
                               })
                               .Features(features =>
                               {
                                   features.Updating().EnableAddRow(true);
                                   features.Updating().EnableDeleteRow(true);
                                   features.Updating().ColumnSettings(settings =>
                                   {
                                       settings.ColumnSetting().ColumnKey("quantity").ReadOnly(false).EditorType(ColumnEditorType.Numeric).Required(true);
                                       settings.ColumnSetting().ColumnKey("item").ReadOnly(false).Required(true);
                                       settings.ColumnSetting().ColumnKey("jobId").ReadOnly(false).EditorType(ColumnEditorType.Text);
                                       settings.ColumnSetting().ColumnKey("glAcct").ReadOnly(false);
                                   });
                               })
                               .DataSource(Model.Items)
                               .PrimaryKey("id")
                               .ClientDataSourceType(ClientDataSourceType.JSON)
                               .Width("100%")
                               .Height("150px")
                               .DataBind()
                               .Render()
                              )
  • 23953
    Offline posted

    Hello David,

    The best way to process data from the igGridUpdating feature is to set the UpdateUrl() and then call the igGrid.saveChanges API to post the changes to a controller action back to the server using an AJAX call.

    This is demonstrated in the Batching Updates sample.

    For more information you can check the igGrid Updating topic.

    Hope this helps,
    Martin Pavlov
    Infragistics, Inc.