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

command.Edit() in UI MVC Grid

2 Answers 844 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Veteran
Andrey asked on 10 Jun 2018, 03:03 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Preslav
Telerik team
answered on 12 Jun 2018, 09:26 AM
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.
0
Andrey
Top achievements
Rank 1
Veteran
answered on 12 Jun 2018, 04:34 PM
Perfect! Thanks Preslav!
Tags
Grid
Asked by
Andrey
Top achievements
Rank 1
Veteran
Answers by
Preslav
Telerik team
Andrey
Top achievements
Rank 1
Veteran
Share this question
or