I use Dapper and bind grid with datatable like this
[controller]
ds = SqlHelper.ExecuteDataset(cn, CommandType.Text, "select id,fullname from tbl_profile_users"); return View("~/Views/user/all.cshtml", ds.Tables[0]);
[view]
@(Html.Infragistics().Grid () .ID("grid1") .Width("100%") .AutoGenerateColumns(false) .AutoGenerateLayouts(true) .RenderCheckboxes(true) .PrimaryKey("id") .Columns(column => { column.For(x => x.id).HeaderText("id").Width("150px"); column.For(x => x.fullname).HeaderText("Fullname").Width("150px"); } ) .Features(features => { features.Paging().PageSize(5).Type(OpType.Remote).Inherit(false); features.Selection().Mode(SelectionMode.Row).MultipleSelection(true); features.Hiding().Inherit(true); features.Filtering(); features.Updating().EnableDeleteRow(true); features.Updating().EnableAddRow(false); }) .DataSource(Model) .DataSourceUrl(Url.Action("all_profiles")) .UpdateUrl(Url.Action("save_profile/")) .DataBind() .Render() )
[script ]
// $(function () { $("#grid1").on("iggridupdatingrowdeleting", function (e, args) { $("#grid1").igGrid("saveChanges"); }); }); // ]]> // $(function () { $("#grid1").on("iggridupdatingrowdeleting", function (e, args) { $("#grid1").igGrid("saveChanges"); }); }); // ]]>
but when delete rows I just get only null ig_transactions,also I Add Watch HttpContext.Request.Form["ig_transactions"] but not have anything value
Hello quang tran,
If your aim is to send the deleted rows' transactions on each delete row operation you can also use the rowDeleted event, which will fire after the row is already deleted. The rowDeleting will fire before the row is delete so there won't be a transaction created for the deleted row yet.
Let me know if you have any additional questions.
Best Regards,
Maya Kirova
Infragistics, Inc.
http://es.infragistics.com/support
Thank you for your answer Maya, it's also works with script
$("#saveChanges").bind({ click: function (e) { $("#grid1").igGrid("saveChanges"); } });
Thank you for posting in our forum.
Are there any errors thrown on the page when you attempt to delete a row?
You can check this by opening your browser’s developer tools (using F12) and checking the Console for any errors. It’s possible that an errors is thrown due to an incorrect PrimaryKey since in your code snippet the primary key:
.PrimaryKey("MaSoBaoDanh")
does not match any of the columns specified for the grid:
.Columns(column => { column.For(x => x.id).HeaderText("id").Width("150px"); column.For(x => x.fullname).HeaderText("Fullname").Width("150px"); } )
Updating requires the PrimaryKey to be set to an existing column in your data source, whose values will serve as an unique identifier for the records in the grid. If the primary key is not set or is not a valid column updating operations (updating, deleting, adding rows) will fail.
I suggest you set the primary key to an existing column, for example:
.PrimaryKey("id")
Let me know if you have any additional questions or concerns.