or
@(Html.Kendo().Grid(Model)
.Name("PatientSearchGrid")
.Columns(columns =>
{
columns.Bound(e => e.LName).Title("Last Name");
columns.Bound(e => e.FName).Title("First Name");
columns.Bound(e => e.ReferralDate);
columns.Bound(e => e.Status);
columns.Bound(e => e.ID).Hidden();
columns.Bound(e => e.ID).ClientTemplate(
"<
a
href
=
'" + Url.Action("GetPatient", "Patient") + "/#= ID #'
" + "
class
=
'btn btn-sm'
>View Patient</
a
>"
).Width(110).Title("");
columns.Bound(e => e.ID).ClientTemplate(
"<
a
href
=
'" + Url.Action("CreateAccount", "Patient") + "/#= ID #'
" + "
class
=
'btn btn-sm'
>Create Account</
a
>"
).Width(127).Title("");
})
.HtmlAttributes(new { style = "height: 390px;" })
.Pageable(pageable => pageable
.PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
.ButtonCount(5))
.Sortable()
.Filterable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Sort(s => s.Add(n => n.LName))
.PageSize(20)
.ServerOperation(false))
//.Events(events => events.DataBound("dataBound"))
)
@(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
>