How to close RadGrid Template EditForm Modal popup?

3 posts, 0 answers
  1. SickPup404
    SickPup404 avatar
    8 posts
    Member since:
    Sep 2014

    Posted 17 Jul 2015 Link to this post

    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. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2302 posts

    Posted 21 Jul 2015 Link to this post

    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
  3. SickPup404
    SickPup404 avatar
    8 posts
    Member since:
    Sep 2014

    Posted 21 Jul 2015 Link to this post

    Great, thanks!

Back to Top