kendo ui - Why does the KendoUI Grid not rollback a delete when the options.error function is called? -
i have put fiddle here demonstrates issue.
http://jsfiddle.net/codeowl/fmzay/1/
just delete record, , should rollback delete calling options.error inside destroy function.
why grid doesn't roll back?
regards,
scott
markup:
<div id="kendogrid"></div>
js:
var _data = [ { users_id: 1, users_fullname: 'bob smith', users_role: 'administrator' }, { users_id: 2, users_fullname: 'barry baker', users_role: 'viewer' }, { users_id: 3, users_fullname: 'bill cow', users_role: 'editor' }, { users_id: 4, users_fullname: 'boris brick', users_role: 'administrator' } ], _datasource = new kendo.data.datasource({ data: _data, destroy: function (options) { options.error(new error('error deleting user')); } }); $('#kendogrid').kendogrid({ datasource: _datasource, columns: [ { field: "users_fullname", title: "full name" }, { field: "users_role", title: "role", width: "130px" }, { command: ["edit", "destroy"], title: " ", width: "180px" } ], toolbar: ['create'], editable: 'popup' });
signaling error not enough. lets having error on removing record not enough since kendoui doesn't know if record has been removed in server , reply 1 producing error. kendoui approach conservative approach: have decide , explicitly it:
so should add error
hander function invokes cancelchanges
in grid.
the code be:
_datasource = new kendo.data.datasource({ transport: { read: function(options) { options.success(_data); console.log('read event has been raised'); }, destroy: function (options) { options.error(new error('error deleting user')); console.log('destroy event has been raised'); } }, schema: { model: { id: "users_id", fields: { users_id: { editable: false, nullable: true }, users_fullname: { type: "string", validation: { required: true } }, users_role: { type: "string", validation: { required: true } } } } }, error: function(a) { $('#kendogrid').data("kendogrid").cancelchanges(); } });
and updated jsfiddle in here: http://jsfiddle.net/onabai/fmzay/3
Comments
Post a Comment