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

Customeditortemplate checkbox with default value only in Add mode not in edit

2 Answers 190 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Anamika
Top achievements
Rank 1
Anamika asked on 16 Sep 2014, 02:50 PM
Hello,

I am using customeditortemplate with a checkbox for SaveinOutlook. taskViewModel has boolean property IsSavedInOutlook and Models.Utility.SaveInOutlook is the default value for add events. My customeditortemplate checkbox is as below
<div class="k-edit-label">
    @(Html.LabelFor(model => model.IsSavedInOutlook))
</div>
<div data-container-for="isSavedInOutlook" class="k-edit-field">
    @if (//add event?? Models.Utility.SaveInOutlook == true)
{
   <input data-bind="checked: isSavedInOutlook" data-val="true" id="IsSavedInOutlook" name="IsSavedInOutlook" type="checkbox" checked/>
} else{
         <input data-bind="checked: isSavedInOutlook" data-val="true" id="IsSavedInOutlook" name="IsSavedInOutlook" type="checkbox" />
}        

</div>

is there a way i can differenciate it is add event or edit event and set checked based on  Models.Utility.SaveInOutlook value? When the customedittemplate popup window comes do a have a way to check add/edit mode and set a default value?

Anamika

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 18 Sep 2014, 08:44 AM
Hello Anamika,

You can determine whether event is added or edited in the edit event of the widget (Edit method for ASP.NET MVC wrapper). In the edit event handler, you can determine whether a new event is added and thus set the isSavedInOutlook field to true or false using the model set method. The event handler should look like something like this:
function edit(e) {
  var event = e.event;
 
  if (event.isNew()) { //event is new (just added)
     event.set("isSavedInOutlook", true);
  }
}

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Anamika
Top achievements
Rank 1
answered on 18 Sep 2014, 09:51 AM
thanks that solves my problem.
Tags
Scheduler
Asked by
Anamika
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Anamika
Top achievements
Rank 1
Share this question
or