@Grid
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" />
<Columns>
. . .
</Columns>
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True" EditMode="DialogTemplate" DialogEditorTemplateID="#protemplate"></EditSettings>
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
</ej:Grid>
@EndADD event
function endAdd(args) {
var len = this.model.dataSource.length;
for (var i = 0; i < len; i++) {
if (i != 0 && args.data.Productcode === this.model.dataSource[i].Productcode) {
this.model.dataSource.splice(0, 1);
this.model.dataSource[i-1].Productname = args.data.Productname;
this.model.dataSource[i-1].qty = args.data.qty;
this.refreshContent();
return false;
}
}
} |
function endAdd(args) {
var len = this.model.dataSource.length;
for (var i = 0; i < len; i++) {
if (i != 0 && args.data.Productcode === this.model.dataSource[i].Productcode) {
this.model.dataSource.splice(0, 1);
this.model.dataSource[i - 1].Productname = args.data.Productname;
this.model.dataSource[i - 1].qty = this.model.dataSource[i - 1].qty+args.data.qty; //here we can add the new qty value with existing one.
this.refreshContent();
return false;
}
}
} |