This is a migrated thread and some comments may be shown as answers.

How to close RadGrid Template EditForm Modal popup?

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SickPup404
Top achievements
Rank 1
SickPup404 asked on 17 Jul 2015, 03:58 PM

Good morning,

 

I have a RadGrid with a Modal Template EditForm.  Everything is working as it should.

The user has requested that they be able to close the Modal EditForm Template by clicking outside the EditForm or by pressing Escape.

I have searched through the forums (and general Google searches) and can't quite get this.

These two threads haven't been any help:

Thread 1

Thread 2

How can I satisfy this request from the user?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 21 Jul 2015, 09:10 AM
Hello,

In order to implement the described behavior you can use the following JavaScript.


function pageLoad() {
    $telerik.$(document).on("keydown", function () {
        var grid = $find("RadGrid1");
        var masterTableView = grid.get_masterTableView();
 
        if (event.keyCode == 27 && grid.get_editItems().length >0) {
            masterTableView.fireCommand("CancelAll", "");
        }
    });
}
 
function gridCreated(sender, args) {
    setTimeout(function () {
        var grid = sender;
        var masterTableView = grid.get_masterTableView();
 
        var modalDiv = $telerik.$(".GridModal_Default");
        if (modalDiv.length > 0) {
            modalDiv.on("click", function () {
                masterTableView.fireCommand("CancelAll", "");
            });
        }
    }, 0);
}


Do not forget to attach the handler for the GridCreated event.


<ClientSettings>
    <ClientEvents OnGridCreated="gridCreated" />
</ClientSettings>


I hope this helps.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
SickPup404
Top achievements
Rank 1
answered on 21 Jul 2015, 12:56 PM

Great, thanks!

Tags
Grid
Asked by
SickPup404
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
SickPup404
Top achievements
Rank 1
Share this question
or