command.Edit() in UI MVC Grid

3 posts, 1 answers
  1. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 10 Jun 2018 Link to this post

    Hello,

    I have to remove the "command.Edit()" from a Grid in GridEditMode.InLine. So one only button "Delete" is displayed. Grid works fine but in the Edit mode (after clicking on "Add New Record" button) the "Update" and "Cancel" buttons will not be displayed so I cannot save a new record. What is possible solution?

    Thanks.

  2. Answer
    Preslav
    Admin
    Preslav avatar
    589 posts

    Posted 12 Jun 2018 Link to this post

    Hi Andrey,

    A possible solution might be handling the edit event of the Grid. In the event handler, based on a condition(if the model is new), manually append the "Update" and "Cancel" buttons, and hide the "Delete" button.

    For example:

    //...
    .Events(e=>e.Edit("onEdit"))
    //...
     
    <script type="text/javascript">
        function onEdit(e) {
            if (e.model.isNew()) {
                var cell = e.container.find(".k-command-cell");
     
                cell.append('<a role="button" class="k-button k-button-icontext k-primary k-grid-update" href="#"><span class="k-icon k-i-check"></span>Update</a>');
                cell.append('<a role="button" class="k-button k-button-icontext k-grid-cancel" href="#"><span class="k-icon k-i-cancel"></span>Cancel</a>');
                cell.find(".k-grid-delete").hide();
            }
        };
    </script>

    I hope this helps.


    Regards,
    Preslav
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Andrey
    Andrey avatar
    49 posts
    Member since:
    Jul 2014

    Posted 12 Jun 2018 in reply to Preslav Link to this post

    Perfect! Thanks Preslav!
Back to Top