Skip to content

Commit 01afef8

Browse files
updated fetching data
1 parent 06bdf6a commit 01afef8

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

grid/autocomplete-editor-allow-setting-new-values/autocomplete-editor-allow-setting-new-values/Controllers/HomeController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Kendo.Mvc.Extensions;
66
using Kendo.Mvc.UI;
77
using SampleApplication.ViewModels;
8+
using System.Linq;
89

910
namespace SampleApplication.Controllers
1011
{
@@ -26,7 +27,9 @@ public JsonResult GetAutocomplete(string text, string methodName)
2627
lookupResults.Add(new ResultEntry("4", "According"));
2728
lookupResults.Add(new ResultEntry("5", "asdas"));
2829

29-
return Json(lookupResults, JsonRequestBehavior.AllowGet);
30+
var newLookupResults = lookupResults.Where(p => p.Name.Contains(text));
31+
32+
return Json(newLookupResults, JsonRequestBehavior.AllowGet);
3033
}
3134

3235
public ActionResult Read([DataSourceRequest] DataSourceRequest request)

grid/autocomplete-editor-allow-setting-new-values/autocomplete-editor-allow-setting-new-values/Views/Home/Index.cshtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@
4040
}
4141
}
4242
}
43+
function onAdditionalData() {
44+
return {
45+
text: $("#Person").val()
46+
};
47+
}
4348
</script>

grid/autocomplete-editor-allow-setting-new-values/autocomplete-editor-allow-setting-new-values/Views/Shared/EditorTemplates/Person.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
.Name("Person")
99
.DataTextField("Name")
1010

11-
.DataSource(dataSource => dataSource.Read(read => read.Action("GetAutocomplete", "Home")).ServerFiltering(true))
11+
.DataSource(dataSource => dataSource.Read(read => read.Action("GetAutocomplete", "Home").Data("onAdditionalData")).ServerFiltering(true))
1212
.HtmlAttributes(new { @class = "k-widget k-autocomplete k-input", style = string.Format("width:200px") })
1313
.Delay(500)
1414

0 commit comments

Comments
 (0)