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

Problem with CustomEditor

1 Answer 78 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
AKROS
Top achievements
Rank 1
AKROS asked on 05 Nov 2016, 10:32 AM

I created a custom editor for my Scheduler, which works well.

Then, I wanted to hide some parts of it with the help of a flag on my ViewModel like this:

<div class="k-edit-label">
@(Html.LabelFor(model => model.Title))
</div>
<div data-container-for="title" class="k-edit-field">
@(Html.TextBoxFor(model => model.Title, new { @class = "k-textbox", data_bind = "value:title" }))
</div>

if(@Model.XXX) {

<div class="k-edit-label">
@(Html.LabelFor(model => model.Description))
</div>
<div data-container-for="description" class="k-edit-field">
@(Html.TextAreaFor(model => model.Description, new { @class = "k-textbox", data_bind = "value:description", rows = 3 }))
</div>
}

But that didn't work. A debugging session shown that my XXX flag was always false. Curiously, if I'm writing something like this

<div data-container-for="xxx" class="k-edit-field">
@(Html.TextBoxFor(model => model.XXX, new { @class = "k-textbox", data_bind = "value:xxx" }))
</div>

I'm seeing the correct value (something true, something false).
So my question is: why using @Model.XXX always return false (the default value of a flag) and how then to implement the behavior I would like?
Thanks & Cheers,

Nicolas

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 08 Nov 2016, 09:20 AM
Hi,

The Editor template is not evaluated on the server. It's used to create a client declaration, that's used by the Scheduler client widget when an event is edited. The if statement is therefore evaluated on the server, where the boolean variable is not bound to any event, and will always return the default value for boolean - false.

If you want to show/hide elements based on what event is loaded, you can use the edit event and use jQuery to access the elements:
http://docs.telerik.com/kendo-ui/api/javascript/ui/scheduler#events-edit

Regards,
Bozhidar
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
Scheduler
Asked by
AKROS
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or