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
185
how to delete more than one row on igGrid ?
posted

If I delete a row and commit the changes, the datasource of the grid has 1 row less, but if I delete two rows and commit the changes , only 1 row is deleted

I´m using infragistics.Web.Mvc version 3.12.1.2023

My grid :

@( Html.Infragistics().Grid<BoletaDetalleView>()
.ID("igGrid")
.Columns(column =>
{

column.For(x => x.ApellidoNombre).DataType("string").HeaderText("Apellido Nombre").Width("50%");
column.For(x => x.CUIL).DataType("int").HeaderText("CUIL").Width("20%");
column.For(x => x.MotivoBajaDescripcion).HeaderText("Motivo Baja").Width("20%");
column.For(x => x.Remuneracion).DataType("number").HeaderText("Remuneracion").Width("10%");
column.For(x => x.AfiliadoId).DataType("int").Hidden(true);
column.For(x => x.PersonalId).DataType("int").Hidden(true);
column.For(x => x.BoletaId).DataType("int").Hidden(true);
column.For(x => x.MotivoBajaId).DataType("int").Hidden(true);
column.For(x => x.ID).DataType("int").HeaderText("ID").Hidden(true);

})

.Features(features =>
{
features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey("ID").AllowSorting(true);

});
features.Selection().MouseDragSelect(true).MultipleSelection(false).Mode(SelectionMode.Row);
features.Updating().EditMode(GridEditMode.Row).EnableAddRow(true).EnableDeleteRow(true);

})

.ClientDataSourceType(ClientDataSourceType.JSON)
.DataSource(new List<BoletaDetalleView>().AsQueryable())
.Width("100%")
.AutoCommit(false)
.DataBind()
.Render()
)

I have a "Save" button. When I click my save button the changes in the igGrid, the dataSource must be sent to my action. this code es executed on save click:

$(function () {
    $("#btnSave").click(function () {
    $("#igGrid").igGrid("commit");

    var dataSource = $("#igGrid").data("igGrid").dataSource.data();

   $.ajax(
          {
          type: 'POST',
          url: "Boleta/Save",
          data: JSON.stringify({ model: modelObject, data: dataSource }), 
          contentType: "application/json, charset=utf-8",
          dataType: "json"
          });

});
});

  • 23953
    Verified Answer
    Offline posted

    Hi,
    In order to work correctly igGridUpdating requires primary key to be defined.
    In your sample you didn't define primary key. Look at the JavaScript console. If you see message like this one:
    "In order to support update operations after a row was deleted, application should define "primaryKey" in options of igGrid." then this is your problem.

    Hope this helps,
    Martin Pavlov
    Infragistics, Inc.