Hi. I define my igGrid in this way:
@( Html.Infragistics().Grid<BoletaDetalleView>()
.ID("igGridDetalle") .RowTemplate("<tr><td> ${ApellidoNombre}</td><td>${CUIL}</td>" + "<td>${MotivoBajaDescripcion}</td>" + "<td>${AfiliadoId}</td>" + "<td>${PersonalId}</td>" + "<td>${BoletaId}</td>" + "<td>${MotivoBajaId}</td>" + "<td>${ID}</td>" + "<td>${Remuneracion}</td></tr>") .PrimaryKey("ID") .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().ColumnSettings(settings => { settings.ColumnSetting() .ColumnKey("MotivoBajaDescripcion") .Required(false) .EditorType(ColumnEditorType.Combo) .ComboEditorOptions(options => { options.TextKey("Descripcion"); options.ValueKey("ID"); options.DataSource(ViewBag.MotivosBaja); options.DropDownMinHeight(200); }); });
.ClientDataSourceType(ClientDataSourceType.JSON) .DataSource(new List<BoletaDetalleView>().AsQueryable()) .Width("100%") .AutoCommit(false) .DataBind() .Render() )
How can I generate primary key when adding a row?
Hi,
You can check out "Adding a PrimaryKey for the AddNewRow" in the igGrid Updating help topic.By default igGridUpdating generates new ID based on the number of rows in the data source.If you want to override this behaviour you can bind to generatePrimaryKeyValue event and provide the new ID yourself.
Hope this helps,Martin PavlovInfragistics, Inc.
Hello. I think this is what I need.
$("#grid1").live("iggridupdatinggenerateprimarykeyvalue", function (event, ui) { ui.value = GENERATE_KEY_HERE });
Thanks