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
375
How add a new row with an object (an adresse for example)
posted

Hello everybody!

 

I am developping a web application.

I am using an igGrid where I can add, modify or delete a row. When editing a row, a dialog is open and I can put some information.

Therefore, I have an address book and then, when I pick up an address (an object with a visible label and an hidden ID), I add a new row that has only the text of the address (didn't save its identifiant)...What I would do is adding an object in a row..(getting both its ID and its label).

Here a part of the code:

 

@{

    ViewBag.Source = AddressBook.Get();

}

 

@(Html.Infragistics().Grid<A_Form_Model>()

    .ID("grid1" .PrimaryKey("IdLineA").RestSettings(rest =>

        rest.RestSetting() .Create(c => c.RestVerbSetting().Url("/api/linea").Batch(true)) .Update(u => u.RestVerbSetting().Url("/api/linea"))

            .Remove(r => r.RestVerbSetting().Url("/api/linea"))

        )

    .Columns(column =>

    {

        column.For(x => x.IdLineA).Hidden(true);

        column.For(x => x.IdAddress).Hidden(true); 

        column.For(x => x.Address).Width("80px");

        column.For(x => x.description).Width("80px");

 })

    .Features(features => 

    {     features.Updating().EditMode(GridEditMode.RowEditTemplate).RowEditDialogContainment("window") .EnableAddRow(true)

            .ColumnSettings(settings =>

            {

                settings.ColumnSetting().ColumnKey("Address").EditorType(ColumnEditorType.Combo)

                    .ComboEditorOptions(options =>

                    {

                        options.DataSource(ViewBag.Source).ValueKey("IdAddress").TextKey("AddressText");                      

                    });

            });

    }) 

    .DataSourceUrl("/api/linea")

    .LocalSchemaTransform(true)

    .DataBind()

    .Render()

    )

 

Hope being clear!

Flo

Parents
  • 3595
    posted

    Hello Aubry,

    Thank you posting in our forum!

    One possible workaround to get the desired behavior is hiding the ID column by setting its width to 1 px instead of setting its “Hidden” property to true. By using this approach the ID field would be visible in the row edit pop-up while it will not be displayed in the grid.

    Hope this solution fits your requirements. If you have any questions, concerns or comments don’t hesitate to update the thread.

Reply Children