Skip to content

Commit

Permalink
Sync with Kendo UI Professional
Browse files Browse the repository at this point in the history
  • Loading branch information
kendo-bot committed Oct 22, 2024
1 parent eeae6c0 commit 888233b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
31 changes: 31 additions & 0 deletions docs-aspnet/html-helpers/data-management/grid/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<kendo-grid on-edit="onEdit">
// Omitted for brevity.
</kendo-grid>
```
{% 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)
Expand Down
12 changes: 6 additions & 6 deletions docs-aspnet/html-helpers/navigation/treeview/binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ public static IList<HierarchicalViewModel> GetHierarchicalData()
{
var result = new List<HierarchicalViewModel>()
{
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;
Expand All @@ -232,7 +232,7 @@ public static IList<HierarchicalViewModel> 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,
Expand Down
4 changes: 4 additions & 0 deletions docs-aspnet/knowledge-base/custom-column-popup-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ 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%})

* [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%})
Expand Down
33 changes: 29 additions & 4 deletions src/kendo.autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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());
}
},
Expand Down
16 changes: 16 additions & 0 deletions tests/autocomplete/separator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 888233b

Please sign in to comment.