or
@(Html.Kendo().DropDownList()
.Name(
"CompanyId"
)
.OptionLabel(
"Choose company"
)
.BindTo(MMHtmlHelperExtension.SelectListForCompany(Model !=
null
? Model.CompanyId :
null
))
.HtmlAttributes(
new
{ data_value_primitive =
"true"
})
)
@(Html.Kendo().DropDownList()
.Name(
"DepartmentId"
)
.OptionLabel(
"Choose department"
)
//We would like to remove this, but if this is removed and the dropdown contains only one element that element cannot be selected
.DataSource(source => source
.Read(read => read.Action(
"GetDepartmentsInCompany"
,
"EditorTemplates"
,
new
{area =
""
}))
.ServerFiltering(
true
))
.Enable(
false
)
.AutoBind(
false
)
.CascadeFrom(
"CompanyId"
)
.HtmlAttributes(
new
{ data_value_primitive =
"true"
})
)
<input id="inputToIllustrateMVVMBehaviour" data-bind="value: DepartmentId" />
departmentDropDownList
.dataSource
.bind(
"change"
,
function
(e) {
if
(departmentDropDownList.select() == 0) {
departmentDropDownList.select(1);
//Visibly changes the dropdown, but does not update the MVVM value
$(
"#DepartmentId_listbox"
).children().eq(1).click();
//Extremely hacky workaround that actually works. Selecting a department manually by clicking also works.
}
});
SO - the main questions:
Best regards
Victor
[HttpGet]
public PartialViewResult GetSearchPartialView(string projectName)
{
RawrSearchAreaModel model = new RawrSearchAreaModel();
// get a list of all window dates from DB
List<
DateTime
> RunDates;
using (RAWREntities dbcontext = new RAWREntities())
{
RunDates = dbcontext.Messages.Where(m => m.ProjectName == projectName).Select(x => x.RunDateTime).Distinct().ToList();
}
JavaScriptSerializer jss = new JavaScriptSerializer();
model.ScheduledDatesJson = jss.Serialize(RunDates.Select(x => x.ToShortDateString()).ToArray());
return PartialView("_rawrSearchArea", model);
}
@(Html.Kendo().DatePicker()
.Name("startDatePicker")
.Events(events =>
{
events.Change("startDateChanged");
}
)
.MonthTemplate("#if ( $.inArray(kendo.toString(new Date(+data.date), 'M/d/yyyy'), " + @Model.ScheduledDatesJson + ") != -1) {#" +
"<
div
class
=
'dateHasWindows'
>" +
"#}else {#" +
"<
div
>" +
"#}#" +
"#= data.value #" +
"</
div
>"
)
)
@(Html.Kendo().DatePicker()
.Name("startDatePicker")
.Events(events =>
{
events.Change("startDateChanged");
}
)
.MonthTemplateId("calendarTemplate")
)
<
script
id
=
"calendarTemplate"
type
=
"text/x-kendo-template"
>
#if ( $.inArray(kendo.toString(new Date(+data.date), 'M/d/yyyy'), " + @Model.ScheduledDatesJson + ") != -1) {#
<
div
class
=
'dateHasWindows'
>
#}else {#
<
div
>
#}#
#= data.value #
</
div
>
</
script
>
//Calculate week sums and total sums
function
gridSave(e) {
var
Mo1_time = e.values.Mo1_time,
Tu1_time = e.model.Tu1_time,
We1_time = e.model.We1_time,
Th1_time = e.model.Th1_time,
Fr1_time = e.model.Fr1_time,
Sa1_time = e.model.Sa1_time,
Su1_time = e.model.Su1_time,
Mo2_time = e.model.Mo2_time,
Tu2_time = e.model.Tu2_time,
We2_time = e.model.We2_time,
Th2_time = e.model.Th2_time,
Fr2_time = e.model.Fr2_time,
Sa2_time = e.model.Sa2_time,
Su2_time = e.model.Su2_time,
Wk1_time = 0,
Wk2_time = 0
Wk1_time = Mo1_time + Tu1_time + We1_time + Th1_time + Fr1_time + Sa1_time + Su1_time;
Wk2_time = Mo2_time + Tu2_time + We2_time + Th2_time + Fr2_time + Sa2_time + Su2_time;
e.model.set(
"Wk1_time"
, Wk1_time);
e.model.set(
"Wk2_time"
, Wk2_time);
e.model.set(
"Sum_time"
, Wk1_time + Wk2_time);
}
columns.Template(e => e.IsChecked).ClientTemplate(
"<input type='checkbox' #= IsChecked ? checked='checked':'' # value='#=EmployeeID#' />"
)