- In the Telerik grid, there was an OnComplete event. What is the Kendo grid equivalent?
- In the Edit client event:
- How do you determine the mode (add or edit)? In the telerik grid it was simply e.mode.
- How do you determine if the cancel click event on the edit form came from the edit or insert mode? In the Telerik grid I could do this:
$(e.form).find(
".t-grid-cancel"
).click(
function
() {
if
(e.mode ==
"insert"
) {
//do insert cancel cleanup code
}
});
3. What is the Kendo equivalent of this:
$(e.form).find(
".t-grid"
).data(
"tGrid"
).ajaxRequest({ InventoryItemId: key });
3. In the Save client event, what would be the equivalent of this code for Kendo?
e.values.inventoryItemId = key;
I think that is enough to start with..
Thanks in advance for any help!
8 Answers, 1 is accepted
The Kendo Grid event documentation can be found here: http://docs.kendoui.com/api/web/grid#events
You can subscribe to events from the MVC wrapper like this:
.Events(e => e.Save(
"onSave"
).Edit(
"onEdit"
))
- There is no direct equivalent of the OnComplete event. Could you please tell us what code were you running there?
- You can use the model field of the edit event arguments and call its isNew method. If it returns true then you are in "insert" mode.
var
insertMode = e.model.isNew();
- Use your existing code combined with the previous suggestion
- The equivalent is this:
this
.dataSource.read({ InventoryItemId: key });
- The equivalent is this:
e.model.set(
"inventoryItemId"
, key);
Atanas Korchev
the Telerik team
I do know where the documentation is, it is just that it is kind of lacking. I see how the events are all documented and the API but there is no documentation on what the "e" parameter gives you in the various api calls or events. This would be very helpful as it is painstaking to try and inspect it at runtime for what you need. Other than that, it has been very helpful in at least finding out what events are available and what api calls are available.
For the "OnComplete" event I was using it to pop up a details window when a custom command button was clicked (this was from one of the Telerik MVC examples). I have found the exampe for Kendo on showing a details popup and have figured out how to use that to get what I need so the OnComplete event is no longer needed.
All your other answers were very helpful, thank you so much! My only problem is that I am still unable to subscribe to the "Cancel" button click event. I am doing it in my edit event and the code is as follows:
function
master_edit(e) {
$(e.form).find(
".k-grid-cancel"
).click(
function
() {
var
insertMode = e.model.isNew();
if
(insertMode) {
var
urlPath =
'@Url.Content( @"~\CatalogAdministration\RemoveBlankInventoryItem?inventoryItemId=")'
;
urlPath += key;
$.post(urlPath);
}
});
this
.dataSource.read({ InventoryItemId: key });
}
The function that is assigned never fires (controller action RemoveBlankInventoryItem is never hit). Am I hooking up to this event incorrectly?
Thanks again!
Could you show us any events that lack event argument documentation? In some cases there is just no data passed in the event arguments.
As for the cancel command I believe the problem stems from the fact that e.form is undefined. The event argument is now called container. This is mentioned in the edit event documentation. You could try changing your code to
$(e.container).find(
".k-grid-cancel"
).click(
function
() {
var
insertMode = e.model.isNew();
if
(insertMode) {
var
urlPath =
'@Url.Content( @"~\CatalogAdministration\RemoveBlankInventoryItem?inventoryItemId=")'
;
urlPath += key;
$.post(urlPath);
}
});
Regards,
Atanas Korchev
the Telerik team
On to your solution... this works great if the Cancel button is actually clicked but on the Telerik side it would also capture if the popup window was closed by hitting the X in the upper right hand corner. This is not the case with the Kendo grid. Is there a way to also capture when the form was closed due to the user hitting the X in the window?
Thanks!
Here is how to handle the window close button as well:
$(e.container).find(
".k-grid-cancel"
).add($(e.container).parent().find(
".k-i-close"
)).click(
function
(e) {
// event handler code
});
Atanas Korchev
the Telerik team
Thanks again!
Thanks again!
Is there any equivalent to this for kendo grid?
Reply would be appreciated