[英]Autocomplete - How can I fire the server-side binding for the datasource after retyping the first few characters
Im using Ajax binding on a Autocomplete widget. 我在自动完成小部件上使用Ajax绑定。 The binding works fine the first time (at the first load of data), but if I back up over the value, it wont go back to the server again (it won't refresh it's dataSource items).
绑定在第一次(在第一次加载数据时)工作正常,但是如果我备份该值,它将不会再次返回到服务器(不会刷新其dataSource项)。 How can I get the dataSource to refresh if I type a new string?
如果键入新的字符串,如何使dataSource刷新?
@(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"))
I think you want to set the ServerOperation
on the Datasource to true, like this: 我认为您想将Datasource上的
ServerOperation
设置为true,如下所示:
.DataSource(dataSource => dataSource
.Read(read => read.Action("CustomerOrders", "Processing"))
.ServerOperation(true)
Since you provide your input text for the read then you have to set the ServerFiltering
( documentation ) for your datasource to true
in order to always filter from the server. 由于您提供了读取的输入文本,因此必须将数据源的
ServerFiltering
( 文档 )设置为true
,以便始终从服务器进行过滤。 I'm guessing that is the way that you want to handle it right? 我猜这就是您要正确处理的方式吗? This will always trigger a server filtering though so if you have a lot of data it might be a good idea to set a MinLength for your requests for example 3-4 like this
但是,这总是会触发服务器过滤,因此,如果您有大量数据,最好为您的请求设置一个MinLength,例如3-4
.MinLength(4)
This way your datasource will read after the first 4 characters are typed and when you delete a character a dataSource.Read will be triggered too. 这样,您的数据源将在键入前四个字符后读取,而当您删除一个字符时,也会触发一个dataSource.Read。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.