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 Mar 4, 2024
1 parent 8b5f64d commit a5482d1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ You can configure the AutoComplete to get its data from a remote source by makin
1. Create an action that returns the data as a JSON result.
{% if site.mvc %}
```C#
public ActionResult Index()
{
return View(new ProductViewModel
Expand All @@ -75,6 +77,31 @@ You can configure the AutoComplete to get its data from a remote source by makin
return Json(products, JsonRequestBehavior.AllowGet);
}
```
{% else %}
```C#
public ActionResult Index()
{
return View(new ProductViewModel
{
ProductID = 4,
ProductName = "ProductName4"
});
}
public JsonResult GetProductsAjax()
{
var products = Enumerable.Range(0, 500).Select(i => new ProductViewModel
{
ProductID = i,
ProductName = "ProductName" + i
});
return Json(products);
}
```
{% endif %}
1. Add the AutoComplete to the view and configure its DataSource to use remote data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ For the complete project, refer to the [AutoComplete in Razor Pages example](htt

In order to set up the AutoComplete component bindings, you need to configure the `Read` method of its `DataSource` instance. The URL in this method should refer the name of the method in the PageModel. In this method, you can also pass additional parameters, such as filter string and antiforgery token (see `dataFunction`).

```tab-HtmlHelper(csthml)
```tab-HtmlHelper(cshtml)
@model IndexModel
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()
@(Html.Kendo().AutoComplete()
.Name("autocomplete")
@(Html.Kendo().AutoCompleteFor(model => model.ShipName)
.DataTextField("ShipName")
.Filter("contains")
.MinLength(3)
Expand Down Expand Up @@ -53,30 +54,36 @@ In order to set up the AutoComplete component bindings, you need to configure th
```
{% if site.core %}
```TagHelper
<kendo-autocomplete name="autocomplete"
datatextfield="ShipName"
filter="FilterType.Contains"
min-length="3">
<datasource type="DataSourceTagHelperType.Custom"
server-filtering="true">
<transport>
<read url="/AutoComplete/AutoCompleteCRUDOperations?handler=Read" data="dataFunction" />
</transport>
</datasource>
</kendo-autocomplete>
<kendo-autocomplete for="ShipName"
datatextfield="ShipName"
filter="FilterType.Contains"
min-length="3">
<datasource type="DataSourceTagHelperType.Custom"
server-filtering="true">
<transport>
<read url="/AutoComplete/AutoCompleteCRUDOperations? handler=Read" data="dataFunction" />
</transport>
</datasource>
</kendo-autocomplete>
```
{% endif %}
```tab-PageModel(cshtml.cs)
public JsonResult OnGetRead(string filterValue)
public class IndexModel : PageModel
{
if (filterValue != null)
[BindProperty]
public string ShipName { get; set; }
public JsonResult OnGetRead(string filterValue)
{
//orders is the DBContext
var filteredData = orders.Where(p => p.ShipName.Contains(filterValue));
return new JsonResult(filteredData);
if (filterValue != null)
{
//orders is the DBContext
var filteredData = orders.Where(p => p.ShipName.Contains (filterValue));
return new JsonResult(filteredData);
}
return new JsonResult(orders);
}
return new JsonResult(orders);
}
```

Expand Down
4 changes: 3 additions & 1 deletion src/kendo.numerictextbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ var __meta__ = {

if (options.value !== undefined) {
that.value(options.value);
} else if (that._value !== undefined) {
that.value(that._value);
}
},

Expand Down Expand Up @@ -371,7 +373,7 @@ var __meta__ = {
adjusted = that._adjust(value);

if (value !== adjusted) {
return;
value = NULL;
}

that._update(value);
Expand Down
34 changes: 30 additions & 4 deletions tests/numerictextbox/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
kendo.culture('en-EN');
});

it("NumericTextBox setOptons works as expected", function() {
it("NumericTextBox setOptions works as expected", function() {
var textbox = new NumericTextBox(input, {
min: 1,
max: 20,
Expand All @@ -555,7 +555,33 @@
assert.equal(textbox.value(), 14);
});

it("NumericTextBox setOptons correctly shows spinners", function() {
it("NumericTextBox setOptions max property is smaller than initial value", function() {
var textbox = new NumericTextBox(input, {
value: 10,
placeholder: "test"
});
textbox.setOptions({
max: 5,
placeholder: "new holder"
});

assert.equal(textbox.value(), null);
});

it("NumericTextBox setOptions max property is larger than initial value", function() {
var textbox = new NumericTextBox(input, {
value: 10,
placeholder: "test"
});
textbox.setOptions({
max: 15,
placeholder: "new holder"
});

assert.equal(textbox.value(), 10);
});

it("NumericTextBox setOptions correctly shows spinners", function() {
var textbox = new NumericTextBox(input, {
spinners: false
});
Expand All @@ -580,7 +606,7 @@
assert.equal(textbox.value(), 11);
});

it("NumericTextBox setOptons correctly sets spinners size", function() {
it("NumericTextBox setOptions correctly sets spinners size", function() {
var textbox = new NumericTextBox(input, {
spinners: true
});
Expand All @@ -593,7 +619,7 @@
assert.equal(textbox._arrowsWrap.find(".k-button-lg").length, 2);
});

it("NumericTextBox setOptons correctly hides spinners", function() {
it("NumericTextBox setOptions correctly hides spinners", function() {
var textbox = new NumericTextBox(input, {
spinners: true
});
Expand Down

0 comments on commit a5482d1

Please sign in to comment.