I'd like to display a message when the changes of a datasource are successfully saved in database, is there a 'success' event as the 'error' event?
Joshua
commented on 25 Feb 2012, 09:08 PM
Top achievements
Rank 1
I am having a problem with this as well. Can you please post if you find a solution?
1 Answer, 1 is accepted
0
Hello,
DataSource change is the event that will be triggered if the operation completes successful.
Regards,
Nikolay Rusev
the Telerik team
DataSource change is the event that will be triggered if the operation completes successful.
Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Joshua
commented on 27 Feb 2012, 04:13 PM
Top achievements
Rank 1
I am currently using the change event to track when data has changed, but it does not fire when an ajax operation fires. If it did, then i do not think it would fit my needs, because i need to know which operation was successful or failed. I have included a snippet to demonstrate what i am trying to do.
In the read and create operations, I would like to know if i have a success or failure during the ajax request. i used the same properties that i used in an $.ajax call that works. for some reason, kendo is just not calling the callback.
In the read and create operations, I would like to know if i have a success or failure during the ajax request. i used the same properties that i used in an $.ajax call that works. for some reason, kendo is just not calling the callback.
var
dataSource =
new
kendo.data.DataSource({
transport: {
read: { url:
'Services/RockService.svc/GetPeople'
,
success:
function
(data) {
alert(data);
},
error:
function
(xhr, error) {
console.debug(xhr); console.debug(error);
}
},
create: {
url:
"Services/RockService.svc/AddPerson"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
success:
function
(data) {
alert(data);
},
error:
function
(xhr, error) {
console.debug(xhr); console.debug(error);
}
},
update: {
url:
"Services/RockService.svc/UpdatePerson"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
},
destroy: {
url:
"Services/RockService.svc/DeletePerson"
,
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
},
parameterMap:
function
(data, type) {
var
ret;
switch
(type) {
case
"read"
:
ret = data;
break
;
case
"destroy"
:
ret = kendo.stringify(data.models[0]);
break
;
default
:
{
var
persons =
new
Array();
for
(
var
i = 0; i < data.models.length; i++) {
persons[i] = data.models[i];
}
ret = kendo.stringify({
"Persons"
: persons });
break
;
}
}
return
ret;
}
},
schema: {
data:
"d"
,
model: Person
},
batch:
true
});
Nikolay Rusev
commented on 29 Feb 2012, 02:49 PM
Telerik team
Hello Joshua,
DataSource change is wired to $.ajax success handler and error event of the DataSource is wired to $.ajax error handler.
Regards,
Nikolay Rusev
the Telerik team
DataSource change is wired to $.ajax success handler and error event of the DataSource is wired to $.ajax error handler.
Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Joshua
commented on 29 Feb 2012, 03:03 PM
Top achievements
Rank 1
But how do you know what operation happend? If it calls the same success and error handlers for all 4 events? How could I let the user know that his Update succeeded vs his Read succeeded or his Delete?
Brendan provided a different solution that is working for me right now:
http://www.kendoui.com/forums/framework/data-source/how-to-get-the-result-true-or-false-of-an-operation-create-update-or-delete-from-the-server.aspx
Brendan provided a different solution that is working for me right now:
http://www.kendoui.com/forums/framework/data-source/how-to-get-the-result-true-or-false-of-an-operation-create-update-or-delete-from-the-server.aspx
Nikolay Rusev
commented on 02 Mar 2012, 05:12 PM
Telerik team
Hello Joshua,
One way is to use complete handler of $.ajax or what's implemented in the thread you mention.
All the best,
Nikolay Rusev
the Telerik team
One way is to use complete handler of $.ajax or what's implemented in the thread you mention.
All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Joshua
commented on 02 Mar 2012, 05:34 PM
Top achievements
Rank 1
jc mag
commented on 06 Mar 2012, 02:50 PM
Top achievements
Rank 1
@Telerik: the datasource change event is triggered too many times. For example, in a grid, as soon as I click on the "Add new record" button, my change function is called... it should be called only when I click on "Save changes"...
Tomas
commented on 16 Mar 2012, 04:00 PM
Top achievements
Rank 1
Hi,
I did some tests and it seems to me, that "change" function can not be wired with ajax "success", because ajax "success" is triggered after data from url are loaded. But if I trigger read on data source, things in "change" are done immediately, not after url in read is loaded.
But when Nikolay says so... :)
Tomas
I did some tests and it seems to me, that "change" function can not be wired with ajax "success", because ajax "success" is triggered after data from url are loaded. But if I trigger read on data source, things in "change" are done immediately, not after url in read is loaded.
But when Nikolay says so... :)
Tomas