or
01.var tree = GetTheListOfSuggestionFromSomewhere();02.var data = _.chain(tree)03. .map(function (t) {04. if (t.parent === "")05. return t.name;06. return undefined;07. })08. .filter(function (t) {09. return typeof t !== "undefined";10. })11. .value();12. 13.console.log(data);// this log out array of string14. 15.var dataSource = new kendo.data.DataSource({16. data: data17.});18.var input = $(element).data("kendoAutoComplete") ||19. $(element).kendoAutoComplete({20. dataSource: tree,21. dataTextField: "path",22. change: function () {23. var path = this.value();24. console.log("selected path ", path);25. 26. },27. filter: "startswith",28. placeholder: "Select path...",29. separator: ""30. }).data("kendoAutoComplete");31. 32.$(element)33. .change(function () {34. value($(this).val());35. console.log("new value", value());36. })37. .val(value())38. .on("keydown", function (e) {39. if (e.which === 110 || e.which === 190) {40. var path = $(this).val() + ".";41. console.log("show the auto complete", path);42. var filtered = _.chain(tree)43. .filter(function (t) {44. return t.parent === path;45. })46. .map(function (t) {47. return t.name;48. })49. .value();50. console.log(filtered);51. //input.setDataSource(dataSource);52. dataSource.data(filtered);53. input.refresh();54. }55. });.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 objectvar 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 variableclientAC.search(window.ClientFullName); window.clientContactAutoCompleteDataItem = clientAC.dataItem(0); --- this is failing01. <script id="LicenceGridTemplate" type="text/kendo-tmpl">02. @(Html.Kendo().Grid<Administration.Models.LicenceModel>()03. .Name("LicenceGrid_#=UserID#")04. .DataSource(dataSource => dataSource05. .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. else22. {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. else56. {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. else68. {69. editable.TemplateName("LicenceRequestTemplate");70. }71. editable.Window(w => w.Width(600));72. })73. .Events(e => e74. .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"; }}