or
.k-dirty {
display
:
block
;
margin
:
-0.4em
0
0
-0.6em
;
position
:
relative
;
}
<
input
type
=
"text"
id
=
"clientContactAutoComplete"
class
=
"k-autocomplete"
/>
$(
"#clientContactAutoComplete"
).kendoAutoComplete({
minlength: 4,
placeholder:
"Select Client Contact"
,
dataSource:
new
kendo.data.DataSource({
serverFiltering:
true
,
transport: {
read: {
url:
'/DataService/LoadContacts'
,
dataType:
"json"
},
parameterMap:
function
() {
return
{
search: $(
"#clientContactAutoComplete"
).data(
"kendoAutoComplete"
).value()
};
},
},
pageSize: 10
}),
dataTextField:
"FullName"
,
template: kendo.template($(
"#clientContactTemplate"
).html()),
style:
"width: 300px"
,
select:
function
(e) {
window.clientContactAutoCompleteDataItem =
this
.dataItem(e.item.index());
// this is the window variable I need to set /////////////////////////
var
fullName = window.clientContactAutoCompleteDataItem.FirstName;
if
(window.clientContactAutoCompleteDataItem.MiddleName !=
null
) {
fullName = fullName +
" "
+ window.clientContactAutoCompleteDataItem.MiddleName;
}
if
(window.clientContactAutoCompleteDataItem.LastName !=
null
) {
fullName = fullName +
" "
+ window.clientContactAutoCompleteDataItem.LastName;
}
window.clientContactAutoCompleteDataItem.FullName = fullName;
// Add DSR information to the display part of the grid if necessary.
if
(!pipelineUtilities.isNullOrEmpty(window.clientContactAutoCompleteDataItem.DSRConsultantName)) {
window.clientContactAutoCompleteDataItem.FullName = window.clientContactAutoCompleteDataItem.FullName +
" {DSR - "
+ window.clientContactAutoCompleteDataItem.DSRConsultantName +
"}"
;
}
GetOffLimitsText();
},
}).data(
"kendoAutoComplete"
);
// get the object
var
clientAC = $(
"#clientContactAutoComplete"
).data(
"kendoAutoComplete"
);
// set the saved value to the field
clientAC.value(window.ClientFullName); ---
this
is working
// get the selected dataItem and set it to the window variable
clientAC.search(window.ClientFullName);
window.clientContactAutoCompleteDataItem = clientAC.dataItem(0); ---
this
is failing
01.
<script id=
"LicenceGridTemplate"
type=
"text/kendo-tmpl"
>
02.
@(Html.Kendo().Grid<Administration.Models.LicenceModel>()
03.
.Name(
"LicenceGrid_#=UserID#"
)
04.
.DataSource(dataSource => dataSource
05.
.Ajax()
06.
.Read(read => read.Action(
"GetLicences"
,
"Licence"
,
new
{ userID =
"#=UserID#"
}).Type(HttpVerbs.Get))
07.
.Model(m =>
08.
{
09.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
10.
{
11.
m.Field(f => f.ApprovalState).DefaultValue(PAService.PartnerEDM.ApprovalState.Approved);
12.
}
13.
m.Id(l => l.LicenceID);
14.
})
15.
.Create(update =>
16.
{
17.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
18.
{
19.
update.Action(
"AddLicence"
,
"Licence"
).Data(
"GetLicenceAdditionalData"
);
20.
}
21.
else
22.
{
23.
update.Action(
"RequestLicence"
,
"Licence"
).Data(
"GetLicenceAdditionalData"
);
24.
}
25.
})
26.
.Update(update =>
27.
{
28.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
29.
{
30.
update.Action(
"EditLicence"
,
"Licence"
).Type(HttpVerbs.Post);
31.
}
32.
})
33.
.Events(e => e.Error(
"grid_error"
))
34.
)
35.
.Columns(columns =>
36.
{
37.
columns.Bound(m => m.ApprovalState);
38.
columns.Bound(m => m.CentralPoint);
39.
columns.Bound(m => m.NextExpirationDate).Format(
"{0:d}"
).HtmlAttributes(
new
{ cellType =
"NextExpirationDate"
}).Width(160);
40.
columns.Bound(m => m.SerialNumber);
41.
columns.Bound(m => m.WebLicenseCount).HtmlAttributes(
new
{ cellType =
"WebCount"
});
42.
columns.Bound(m => m.MobileLicenseCount).HtmlAttributes(
new
{ cellType =
"MobileCount"
});
43.
columns.Bound(m => m.ExcelAddInLicenseCount).HtmlAttributes(
new
{ cellType =
"ExcelCount"
});
44.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
45.
{
46.
columns.Command(command => command.Edit().Text(
" "
)).Width(100);
47.
}
48.
})
49.
.ToolBar(toolbar =>
50.
{
51.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
52.
{
53.
toolbar.Create().Text(@ressourceManager.GetString(
"Add"
));
54.
}
55.
else
56.
{
57.
toolbar.Create().Text(@ressourceManager.GetString(
"RequestLicence"
));
58.
}
59.
})
60.
.Editable(editable =>
61.
{
62.
editable.Mode(GridEditMode.PopUp);
63.
if
(currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
64.
{
65.
editable.TemplateName(
"LicenceEditTemplate"
);
66.
}
67.
else
68.
{
69.
editable.TemplateName(
"LicenceRequestTemplate"
);
70.
}
71.
editable.Window(w => w.Width(600));
72.
})
73.
.Events(e => e
74.
.Edit(
"AdaptLicenceEditPopup"
)
75.
.DataBound(
"UpdateDatesColors"
)
76.
.Save(
"UpdateCalculatedFields"
)
77.
.DetailExpand(
"grid_detailexpand"
)
78.
.Cancel(
"Cancel"
)
79.
)
80.
.Sortable()
81.
.Filterable()
82.
.Resizable(resize => resize.Columns(
true
))
83.
.ToClientTemplate()
84.
)
85.
</script>
1.
@Html.LabelFor(l => l.IsDemo)
1.
[LocalizedDisplayName(
"IsDemoLicence"
)]
2.
public
bool
IsDemo {
get
;
set
; }
window.onbeforeunload = confirmLeavePage();
function
confirmLeavePage() {
debugger;
var
dataSource = $(
"#ValuesGrid"
).data(
"kendoGrid"
).dataSource;
var
data = dataSource.data();
var
hasChanges = dataSource.hasChanges();
for
(
var
loop = 0; loop < data.length; loop++) {
if
(data[loop].dirty) {
hasChanges =
true
;
break
;
}
}
if
(hasChanges) {
return
"You have made changes to the current values. The changes will be lost if you leave this page without clicking the save button"
;
}
}
<
p
>
<
label
class
=
"searchLabel"
for
=
"state"
>State:</
label
>
@(Html.Kendo().DropDownList()
.Name("state")
.HtmlAttributes(new { style = "width:275px" })
.OptionLabel("Select state...")
.DataTextField("StateName")
.DataValueField("StateAbbr")
.DataSource(source => source.Read(read => read.Action("GetStates", "Home")))
)
</
p
>
<
p
>
<
label
class
=
"searchLabel"
for
=
"county"
>County:</
label
>
@(Html.Kendo().DropDownList()
.Name("county")
.HtmlAttributes(new { style = "width:275px" })
.OptionLabel("Select county...")
.DataTextField("CountyName")
.DataValueField("CountyName")
.DataSource(source => source.Read(read => read.Action("GetCounties", "Home").Data("filterCounties"))
.ServerFiltering(true))
.Enable(false)
.AutoBind(false)
.CascadeFrom("state")
)
</
p
>
<
p
>
<
label
class
=
"searchLabel"
for
=
"city"
>City:</
label
>
@(Html.Kendo().DropDownList()
.Name("city")
.HtmlAttributes(new { style = "width:275px" })
.OptionLabel("Select city...")
.DataTextField("CityName")
.DataValueField("CityName")
.DataSource(source => source.Read(read => read.Action("GetCities", "Home").Data("filterCities"))
.ServerFiltering(true))
.Enable(false)
.AutoBind(false)
.CascadeFrom("county")
)
</
p
>
<
script
>
function filterCounties() {
return {
state: $("#state").val()
};
}
function filterCities() {
return {
state: $("#state").val(),
county: $("#county").val()
};
}
$(document).ready(function() {
$("#state").data("kendoDropDownList");
$("#county").data("kendoDropDownList");
$("#city").data("kendoDropDownList");
});
</
script
>
$("#grouping").click(function () {
$("#grid").data("kendoGrid").groupable(true);
});
$("#removegrouping").click(function () {
$("#grid").data("kendoGrid").groupable(false);
});
$("#sorting").click(function () {
$("#grid").data("kendoGrid").sorting(true);
});