- Home
- Forum
- ASP.NET MVC
- Click edit on any row but the first and the values fill with previous row's values?
Click edit on any row but the first and the values fill with previous row's values?
.AllowPaging() /*Paging Enabled*/
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).AllowEditing(true).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();
})
{
child.Datasource(ds => ds.URL(@Url.Action("ChildDataSource"))
.InsertURL(@Url.Action("ChildInsert"))
.UpdateURL(@Url.Action("Update"))
.RemoveURL(@Url.Action("Delete"))
.Adaptor(AdaptorType.UrlAdaptor))
.QueryString("OrderID")
{
edit.AllowAdding().AllowDeleting().AllowEditing()
.RowPosition(RowPosition.Top)
.ShowDeleteConfirmDialog(true)
;
})
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Visible(false).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("ProductName").HeaderText("Product Name").Width(120).Add();
col.Field("Quantity").Width(100).Add();
col.Field("ExtendedPrice").Width(100).Add();
});
})
)
function actionComplete(args) {
var $edit = $("form[id$='EditForm']");
$edit.on("keypress keyup keydown", preventEnterKey);
};
};
function preventEnterKey(e) {
if (e.which === 13 || e.which === 169) {
e.preventDefault();
return false;
};
return true;
}
</script>
Attachment: Grid_image_9d84484d.zip
Thanks for contacting Syncfusion support.
In Grid the Editing operation is performed based on the primary key field and it must be a unique values. But In provided code snippets you have used the IsPrimaryKey and QueryString to the same field name “OrderID”, So while editing the second row the first row data is displayed.
| @(Html.EJ().Grid<OrdersView>("FlatGrid")
.Datasource(Model)
. . .
.ChildGrid(child => { child.Datasource(ds => ds.URL(@Url.Action("ChildDataSource")) .InsertURL(@Url.Action("ChildInsert")) .UpdateURL(@Url.Action("Update")) .RemoveURL(@Url.Action("Delete")) .Adaptor(AdaptorType.UrlAdaptor)) .QueryString("OrderID")
. . .
.ClientSideEvents(evnt => evnt.ActionComplete("actionComplete"))
.Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("ProductName").HeaderText("Product Name").Width(120).Add(); col.Field("Quantity").Width(100).Add(); col.Field("ExtendedPrice").Width(100).Add(); }); }) |
To overcome this issue, we suggest you to use the different field name (unique value field) to the primary key column and set the IsPrimaryKey to the unique value field in Child Grid.
If you still face the issue, kindly share your sample with Essential studio version details.
Regards,
Balaji Marimuthu
Thanks for the update.
We are happy to hear that you requirement is achieved.
Regards,
Venkatesh Ayothiraman.
- 3 Replies
- 3 Participants
-
CK Cindy Kee
- Apr 6, 2016 04:58 AM UTC
- Apr 12, 2016 05:23 AM UTC