Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI grid - different templates for Edit and Create

Tags:

kendo-ui

We are using Kendo UI grid to display some records. The requirements need us to have a column (Say "File Name")shown as a text box when the user clicks on "Edit". However, when user clicks on the "Create" button in the toolbar, the same column should be replaced with a File Select control which will allow the user to select a file from his machine. The other columns remain the same. I have already tried searching through Stack Overflow as well as the Kendo UI Grid forums, but to no avail. Is there any way to achieve this? Any pointers will be of great help.

Regards, Nikhil

like image 781
nikhil Avatar asked Jan 14 '13 15:01

nikhil


People also ask

How do I change my Kendo grid theme?

Just replace kendo. default. min. css file from the <head> section of the page with the name of the theme you would like to use.

How do I get the edited row in kendo grid?

dataSource. get(e. model. get("Id")) gets the newly added row, but if multiple rows were added before saving, it will always get the first added row ("Id" is set to auto increment and is automatically generated by the database server, therefore all newly created rows will initially have 0 before saving).

What is client template in kendo grid?

Define the client template using Kendo UI Template syntax. The context of the template is the Category entity to which the current Grid row is bound. The template itself contains another Grid which is bound to the Products_Read action.

What is Dataitem in kendo grid?

Returns the data item to which the specified table row is bound. The data item is a Kendo UI Model instance.


1 Answers

Using different editor templates for create/edit is not supported. You need to use the edit event of the Grid to change that text input to file input with JavaScript. To distinguish between edit and create you can use the isNew() method of the model. i.e.

edit:function(e){
      if(e.model.isNew()){
          //replacement logic
      }
 }

Similar question is covered here.

like image 144
Petur Subev Avatar answered Sep 30 '22 19:09

Petur Subev