I have created a listview bound to a remote datasource. I have added a delete button using the k-delete-button class, and clicking on the button does remove the item from the listview. My question is can I optionally cancel the remove event? My first assumption was that I would implement the remove event on the listView, could implement any needed business logic, and optionally cancel the remove operation. I was able to catch the event and the model was passed with the record that was removed, but I can't seem to find any way to cancel the operation. No matter what I do, the listview item that was removed does not return to the screen.
5 Answers, 1 is accepted
0
Accepted
Hello Volkan,
You can call preventDefault in order to prevent further execution of the handler. For example:
Regards,
Nikolay Rusev
the Telerik team
You can call preventDefault in order to prevent further execution of the handler. For example:
listview.bind(
"remove"
,
function
(e) {
if
(!confirm("Are you sure?)) e.preventDefault();
})
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!
0
Volkan
Top achievements
Rank 1
answered on 31 Jan 2013, 03:45 PM
Thanks,
I did try that, but it appears that the item has already been removed from the listview before the execution of the remove event. From what I can tell the preventDefault only prevents the DataSync event?
I did try that, but it appears that the item has already been removed from the listview before the execution of the remove event. From what I can tell the preventDefault only prevents the DataSync event?
0
Hello Volkan,
Here is a working sample:
http://jsbin.com/oxeqik/3/edit
We are not sure how you observe described behavior. Clicking cancel in the confirmation dialog prevent item remove.
Regards,
Nikolay Rusev
the Telerik team
Here is a working sample:
http://jsbin.com/oxeqik/3/edit
We are not sure how you observe described behavior. Clicking cancel in the confirmation dialog prevent item remove.
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!
0
Dragan
Top achievements
Rank 1
answered on 12 Mar 2013, 09:01 AM
Nikolay,
What do you do if the server logic cannot delete the item for any reason? I think that is what Volkan is asking you about. When you click OK on that confirmation box, it will delete the item without taking care if the delete REALLY took place.
If you look at the code in js file, you will notice that this is what is happening at both grid and listview, items get removed once user clicks on that OK button in confirmation box. What would be the way to change that behavior at listview or grid?
What do you do if the server logic cannot delete the item for any reason? I think that is what Volkan is asking you about. When you click OK on that confirmation box, it will delete the item without taking care if the delete REALLY took place.
If you look at the code in js file, you will notice that this is what is happening at both grid and listview, items get removed once user clicks on that OK button in confirmation box. What would be the way to change that behavior at listview or grid?
0
Hello Dragan,
Nikolay Rusev
the Telerik team
If that's what you need you can handle DataSource.error event and call cancelChanges in order to revert back hidden items on error.
Here is a sample demonstrating this: http://jsbin.com/oxeqik/12/edit
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!