自动完成 - 如何在重新输入前几个字符后触发数据源的服务器端绑定
Autocomplete - How can I fire the server-side binding for the datasource after retyping the first few characters
我在自动完成小部件上使用 Ajax 绑定。绑定第一次工作正常(在第一次加载数据时),但如果我备份该值,它不会再次返回到服务器(它不会刷新它的数据源项目)。如果输入新字符串,如何让数据源刷新?
@(Html.Kendo().AutoComplete()
.Name("Orders")
.HtmlAttributes(new { style = "background-color:lightyellow;width:300px;" })
.Events(e =>
{
e.Select("selectOrder");
})
.Filter("startswith")
.Placeholder("Select order or enter new one")
.Filter("startswith")
.MinLength(3)
.DataSource(dataSource => dataSource
.Read(read => read.Action("CustomerOrders", "Processing")
.Type(HttpVerbs.Post).Data("getInputs"))).DataTextField("HouseNo"))
我认为您想将数据源上的 ServerOperation
设置为 true,如下所示:
.DataSource(dataSource => dataSource
.Read(read => read.Action("CustomerOrders", "Processing"))
.ServerOperation(true)
由于您为读取提供了输入文本,因此您必须将数据源的 ServerFiltering
(documentation) 设置为 true
,以便始终从服务器进行过滤。我猜这就是您想正确处理它的方式?
这将始终触发服务器过滤,因此如果您有大量数据,最好为您的请求设置一个 MinLength,例如 3-4,如下所示
.MinLength(4)
这样您的数据源将在键入前 4 个字符后读取,并且当您删除一个字符时也会触发 dataSource.Read。
我在自动完成小部件上使用 Ajax 绑定。绑定第一次工作正常(在第一次加载数据时),但如果我备份该值,它不会再次返回到服务器(它不会刷新它的数据源项目)。如果输入新字符串,如何让数据源刷新?
@(Html.Kendo().AutoComplete()
.Name("Orders")
.HtmlAttributes(new { style = "background-color:lightyellow;width:300px;" })
.Events(e =>
{
e.Select("selectOrder");
})
.Filter("startswith")
.Placeholder("Select order or enter new one")
.Filter("startswith")
.MinLength(3)
.DataSource(dataSource => dataSource
.Read(read => read.Action("CustomerOrders", "Processing")
.Type(HttpVerbs.Post).Data("getInputs"))).DataTextField("HouseNo"))
我认为您想将数据源上的 ServerOperation
设置为 true,如下所示:
.DataSource(dataSource => dataSource
.Read(read => read.Action("CustomerOrders", "Processing"))
.ServerOperation(true)
由于您为读取提供了输入文本,因此您必须将数据源的 ServerFiltering
(documentation) 设置为 true
,以便始终从服务器进行过滤。我猜这就是您想正确处理它的方式?
这将始终触发服务器过滤,因此如果您有大量数据,最好为您的请求设置一个 MinLength,例如 3-4,如下所示
.MinLength(4)
这样您的数据源将在键入前 4 个字符后读取,并且当您删除一个字符时也会触发 dataSource.Read。