BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
this.actionBegin = function (args) {
if (args.requestType == "endedit") { //it must be args.requestType == “save” if you intend to prevent default server-side save operation args.Cancel = true; } |
I have send all code..
I have done following code in API
for update operation::
[HttpPut]
public void GetGroupListByClientId(GroupDTO GroupDTO)
{
GroupService.Edit(GroupDTO);
}
For Delete operation::::
[HttpDelete]
public bool GetGroupListByClientId(int Id)
{
return GroupService.Delete(Id);
}
[HttpGet]
public object GetGroupListByClientId(string accessId, string clientId)
{
var queryString = HttpContext.Current.Request.QueryString;
string access = queryString["accessId"];
int ClientId = Convert.ToInt32(queryString["clientId"]);
return new { result = GroupService.GetGroupListByClientId(ClientId) };
}
HTML code for grid
<div ng-controller="GroupController as group">
<div id="Grid" ej-grid e-datasource="group.data" e-query="group.query" e-columns="group.columns" e-editsettings="group.edittsetings" e-allowsorting="group.allowsorting" e-sortsettings="group.sortsettings" e-editsettings="group.editsettings" e-actioncomplete="group.complete" e-enablerowhover="false" e-enableautosaveonselectionchange="false"></div>
</div>
function GroupController(GroupService, $route, $location, $http) {
var newColumns = [
{ field: "Id", headerText: "ID", isPrimaryKey: true, textAlign: ej.TextAlign.Right, width: 75, visible: false },
{ field: "ClientID", headerText: "ClientID", isPrimaryKey: true, textAlign: ej.TextAlign.Right, width: 75, visible: false },
{ field: "Name", headerText: "Group Name", width: 90 },
{
headerText: "",
commands: [
{ type: ej.Grid.UnboundType.Edit, buttonOptions: { text: "Edit" } },
{ type: ej.Grid.UnboundType.Delete, buttonOptions: { text: "Delete" } },
{ type: ej.Grid.UnboundType.Save, buttonOptions: { text: "Save" } },
{ type: ej.Grid.UnboundType.Cancel, buttonOptions: { text: "Cancel" } }
],
isUnbound: true, width: 130, textAlign: ej.TextAlign.Right
}
];
this.columns = newColumns;
this.data = ej.DataManager({ url: "http://localhost:63138/api/Group/GetGroupListByClientId", adaptor: "WebApiAdaptor" }),
this.query = new ej.Query().addParams('clientId', '1').addParams('accessId', '1');
this.edittsetings = { allowEditing: true, allowAdding: true, allowDeleting: true, allowEditOnDblClick: false };
this.complete = function (args) {
if (args.requestType == "save") {
alert(JSON.stringify(args))
console.log("success");
}
console.log(args);
if (args.requestType == "delete") {
//alert(JSON.stringify(args))
// console.log(args)
toastr.options = { "positionClass": "toast-bottom-right" }
toastr.success('Success', 'Group deleted successfully!')
}
}
}
Using above all code i have done add and delete operations but for update operation call is going to API for update operation but changes not reflected to view because after click on edit button it become save button but after click on save button it is not seen again back edit button it give error like
Uncaught TypeError: Cannot read property 'record' of undefined(anonymous function) @ ej.web.all.min.js:10n.Callbacks.j @ jquery-2.1.1.min.js:2n.Callbacks.k.fireWith @ jquery-2.1.1.min.js:2x @ jquery-2.1.1.min.js:4n.ajaxTransport.k.cors.a.crossDomain.send.b @ jquery-2.1.1.min.js:4
[HttpPut] public object GetGroupListByClientId(EmployeePhoto employee) {
} |