简体   繁体   English

自动完成-重新键入前几个字符后,如何为数据源激发服务器端绑定

[英]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.

相关问题 如何构造返回JSON对象的服务器端数据源? - How to structure a server-side datasource that returns JSON objects? 如何获取服务器端控件的标签? - How can I get a server-side control's tag? 如何在 Blazor 服务器端的 CircuitHandler 中调用方法? - How can I invoke method in CircuitHandler of Blazor server-side? 如何从服务器端向客户端发送变量? - How can I send a variable from the Server-side to the Client-side? 如何从asp.net-webpages中的Ajax请求获取服务器端的发布文件? - How can I get a posted file on server-side from an Ajax Request in asp.net-webpages? 如何有条件地阻止表单在服务器端/代码背后提交? - How can I conditionally prevent a form from submitting with server-side/code-behind? 如何使用Process.Start()通过Web服务在服务器端执行程序? - How can I use Process.Start() to execute program on the server-side via web service? 如何使用 ASP.NET 删除浏览器的缓存服务器端? - How can I remove a browser's cache server-side, using ASP.NET? 如何从jQuery(Sharepoint 2010)调用服务器端事件? - How can I invoke a server-side event from jQuery (Sharepoint 2010)? 如何使用 .Net (C#) 在服务器端将原始 HTML 转换为 Markdown? - How can I convert raw HTML to Markdown, server-side using .Net (C#)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM