diff --git a/docs-aspnet/html-helpers/data-management/grid/faq.md b/docs-aspnet/html-helpers/data-management/grid/faq.md index 6ce0b242601..3d5b374b601 100644 --- a/docs-aspnet/html-helpers/data-management/grid/faq.md +++ b/docs-aspnet/html-helpers/data-management/grid/faq.md @@ -858,6 +858,37 @@ To validate a number by using the Kendo UI NumericTextBox: public decimal Price { get; set; } } +## How can I distinguish between Add and Edit mode? + +To distinguish between the insert and update modes, you can use the `isNew` method in combination with the edit event handler of the grid: +[Grid Edit Event](http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-edit) + +Here is a basic sample for reference: + +```HtmlHelper + // Omitted for brevity. + .Events(events => events.Edit("onEdit")) +``` +{% if site.core %} +```TagHelper + + // Omitted for brevity. + +``` +{% endif %} +```js +function onEdit(args) { + if (args.model.isNew() == false) { + // textbox + $("#ShipName").attr("readonly", true); + + // dropdownlist + var kendoDdl = $("#ShipCountry").data("kendoDropDownList"); + kendoDdl.readonly(true); + } +} +``` + ## See Also * [Basic Usage of the Grid HtmlHelper for {{ site.framework }} (Demo)](https://demos.telerik.com/{{ site.platform }}/grid) diff --git a/docs-aspnet/html-helpers/navigation/treeview/binding.md b/docs-aspnet/html-helpers/navigation/treeview/binding.md index 4e87e970dc3..052a6ce7873 100644 --- a/docs-aspnet/html-helpers/navigation/treeview/binding.md +++ b/docs-aspnet/html-helpers/navigation/treeview/binding.md @@ -219,11 +219,11 @@ public static IList GetHierarchicalData() { var result = new List() { - new HierarchicalViewModel() { ID = 1, ParendID = null, HasChildren = true, Name = "Parent item" }, - new HierarchicalViewModel() { ID = 2, ParendID = 1, HasChildren = true, Name = "Parent item" }, - new HierarchicalViewModel() { ID = 3, ParendID = 1, HasChildren = false, Name = "Item" }, - new HierarchicalViewModel() { ID = 4, ParendID = 2, HasChildren = false, Name = "Item" }, - new HierarchicalViewModel() { ID = 5, ParendID = 2, HasChildren = false, Name = "Item" } + new HierarchicalViewModel() { ID = 1, ParentID = null, HasChildren = true, Name = "Parent item" }, + new HierarchicalViewModel() { ID = 2, ParentID = 1, HasChildren = true, Name = "Parent item" }, + new HierarchicalViewModel() { ID = 3, ParentID = 1, HasChildren = false, Name = "Item" }, + new HierarchicalViewModel() { ID = 4, ParentID = 2, HasChildren = false, Name = "Item" }, + new HierarchicalViewModel() { ID = 5, ParentID = 2, HasChildren = false, Name = "Item" } }; return result; @@ -232,7 +232,7 @@ public static IList GetHierarchicalData() public ActionResult Read_TreeViewData(int? id) { var result = GetHierarchicalData() - .Where(x => id.HasValue ? x.ParendID == id : x.ParendID == null) + .Where(x => id.HasValue ? x.ParentID == id : x.ParentID == null) .Select(item => new { id = item.ID, Name = item.Name, diff --git a/docs-aspnet/knowledge-base/custom-column-popup-editor.md b/docs-aspnet/knowledge-base/custom-column-popup-editor.md index 21da4a2e8b1..4657e4ae331 100644 --- a/docs-aspnet/knowledge-base/custom-column-popup-editor.md +++ b/docs-aspnet/knowledge-base/custom-column-popup-editor.md @@ -121,6 +121,8 @@ For the complete implementation of the suggested approach, refer to the followin * [{{ site.framework }} Grid Demos](https://demos.telerik.com/{{ site.platform }}/grid/index) {% if site.core %} +* [{{ site.framework }} Grid Custom PopUp Editor Example](https://github.com/telerik/ui-for-aspnet-core-examples/blob/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Views/Grid/CustomPopUpEditor.cshtml) + * [{{ site.framework }} Grid Product Page](https://www.telerik.com/aspnet-core-ui/grid) * [Telerik UI for {{ site.framework }} Video Onboarding Course (Free for trial users and license holders)]({%slug virtualclass_uiforcore%}) @@ -128,6 +130,8 @@ For the complete implementation of the suggested approach, refer to the followin * [Telerik UI for {{ site.framework }} Forums](https://www.telerik.com/forums/aspnet-core-ui) {% else %} +* [{{ site.framework }} Grid Custom PopUp Editor Example](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridEditingCustomPopupEditor) + * [{{ site.framework }} Grid Product Page](https://www.telerik.com/aspnet-mvc/grid) * [Telerik UI for {{ site.framework }} Video Onboarding Course (Free for trial users and license holders)]({%slug virtualclass_uiformvc%}) diff --git a/src/kendo.autocomplete.js b/src/kendo.autocomplete.js index a61bb51b0ba..c0162accc4f 100644 --- a/src/kendo.autocomplete.js +++ b/src/kendo.autocomplete.js @@ -401,6 +401,7 @@ var __meta__ = { var that = this, key = that._last, value = that._accessor(), + currentValue = that.value(), element = that.element[0], caretIdx = caret(element)[0], separator = that._separator(), @@ -429,8 +430,8 @@ var __meta__ = { caretIdx = (accentFoldingFiltering ? value.toLocaleLowerCase(accentFoldingFiltering) : value.toLowerCase()).indexOf(accentFoldingFiltering ? word.toLocaleLowerCase(accentFoldingFiltering) : word.toLowerCase()) + 1; } - idx = value.substring(0, caretIdx).lastIndexOf(separator); - idx = idx > -1 ? caretIdx - (idx + separator.length) : caretIdx; + idx = value.substring(0, caretIdx).lastIndexOf(that._defaultSeparator()); + idx = idx > -1 ? caretIdx - (idx + that._defaultSeparator().length) : caretIdx; value = words[wordIndex].substring(0, idx); if (word) { @@ -452,7 +453,20 @@ var __meta__ = { words[wordIndex] = value; - that._accessor(words.join(separator || "")); + if (typeof that.options.separator == 'object' && that.options.separator != null) { + if (currentValue.length > 1) { + let lastSeparator = [...currentValue.matchAll(separator.source)].pop(); + if (lastSeparator) { + that._accessor(words.slice(0, -1).join(that._defaultSeparator() || "") + lastSeparator + words[words.length - 1]); + } else { + that._accessor(words.slice(0, -1).join(that._defaultSeparator() || "")); + } + } else { + that._accessor(words.join(this._defaultSeparator() || "")); + } + } else { + that._accessor(words.join(separator || "")); + } if (element === activeElement()) { caret(element, caretIdx, selectionEnd); @@ -752,7 +766,18 @@ var __meta__ = { _move: function(action) { this.listView[action](); - if (this.options.suggest) { + if (this.options.suggest && this.listView.focus() == null && action == "focusNext") { + this.listView.focus(0); + this.suggest(this.listView._view[0].item); + } else if (this.options.suggest && this.listView.focus() == null && action == "focusPrev") { + let index = this.listView._view.length - 1; + this.listView.focus(index); + this.suggest(this.listView._view[index].item); + } else if (this.options.suggest && action == "focusFirst") { + caret(this.element)[0]; + } else if (this.options.suggest && action == "focusLast") { + caret(this.element)[this.element.val().length - 1]; + } else if (this.options.suggest && this.listView.focus() != null) { this.suggest(this.listView.focus()); } }, diff --git a/tests/autocomplete/separator.js b/tests/autocomplete/separator.js index 9fc51f9b593..c1739e003f1 100644 --- a/tests/autocomplete/separator.js +++ b/tests/autocomplete/separator.js @@ -117,6 +117,22 @@ it("select replaces the word at the caret position", function() { autocomplete.search(); }); + it("multiple separators, suggest correct word", function() { + var autocomplete = new AutoComplete(input, { + separator: [", ", ": ", "; "], + suggest: true, + dataSource: { + data: ["baz", "bar"] + } + }); + + input.focus(); + input.type("b"); + autocomplete.search(); + + assert.equal(input.val(), "baz, "); + }); + it("multiple separators, replace all with default separator", function() { var autocomplete = new AutoComplete(input, { dataSource: ["baz", "bar"],