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

Kendo UI MVC grid popup edit template depending on row condition

2 Answers 343 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dongfen
Top achievements
Rank 1
Dongfen asked on 25 Jun 2014, 10:35 PM
Hello,

I have a kendo UI MVC grid, I use the popup edit template.
And I created a customer edit templates.  My model has a property as type (holds three different values).
For different type, my edit template condition changes.  

For example, the release date - for Type 1, it is read only; for Type 2, it is editable; and for Type 3, the label needs to be changed slightly.

I tried to use if statement in the partial view (custom edit template) to check.  But it does not work since popup edit template is loaded when grid is loaded.

So is there a way that I can accomplish what I described here with  kendo UI grid?

Thanks in advance

Dongfen Gao

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Jun 2014, 04:14 PM
Hello,

There are two options:

1. Use JavaScript - handle the edit event of the grid and show/hide parts of the UI via jQuery:

@(Html.Kendo().Grid()
            .Events(e => e.Edit("edit"))

<script>
function edit(e) {
   // check for a property of the model which is being edited
   if (e.model.Type == "Type 1") {
         // manipulate the edit form via jQuery
         e.container.find("label").text("Type 1");
   }
}
</script>

2. Use server binding and editing. Then you can use if statements in the editor template itself and don't have to write any JavaScript.

Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dongfen
Top achievements
Rank 1
answered on 01 Jul 2014, 03:44 PM
Thank you.
I used the server edit option and it works fine now.
Tags
Grid
Asked by
Dongfen
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Dongfen
Top achievements
Rank 1
Share this question
or