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

Grid Editor - Insert or Edit mode?

2 Answers 475 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 01 Jan 2019, 07:22 PM
I have the following in a Kendo UI MVC Core Grid to declare that a popup shows when adding or inserting a record:

.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Template").Window(x => x.Width(500).Height(500)))

That works to bring up the editor template popup which is stored in the Shared/EditorTemplates folder.  And validation is working as well as the Insert or Update methods on the controller are working. 
Yet the when I click the +ADD NEW RECORD button on the Toolbar when the dialog shows it always shows as an update   action. The title bar displays "Edit" and the button displays "Update".  This is happening in another grid as well.  Shouldn't it display "Insert" and "Save" or "Insert" and "Add" when the +ADD NEW RECORD button on the Toolbar is clicked?  Why always "Edit"?

I also need to know if it is in Insert or Edit mode at run-time because I am doing a lookup using Ajax when the user enters a value to check for duplicates on that particular field.

Please advise.

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 02 Jan 2019, 11:00 AM
Hi Reid,

In order to change the title of the popup window and the text for the buttons I would suggest handling the edit event. In the event handler get reference of the popup window and change the title for it. In the same event you can change the text of the update/create button.

The code snippets below show the relevant code. 

Handle the edit event:

.Events(e=>e.Edit("onEdit"))

JavaScript handler:

function onEdit(e) {
    if (e.model.isNew()) {
        e.container.kendoWindow("title", "Create");
        e.container.find(".k-grid-update").contents()[1].textContent = "Create";
    }
}


Give the approach a try and let me know how it works for you.


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Sven
Top achievements
Rank 1
commented on 24 Nov 2022, 08:35 AM | edited

There is no Edit event any more. Only Open exists so far.

 

Sorry, I was wrong. The Edit event on the Grid component still exists.

 

0
Reid
Top achievements
Rank 2
answered on 02 Jan 2019, 01:14 PM
Thank you Viktor, that works.
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Reid
Top achievements
Rank 2
Share this question
or