Good morning one and all,
May be my Heading question is wrong but here i will explain what i need,
i have table with Country in db, now i want to search with auto complete in kendo grid it should display which latter i'm passing then get only those items(like i'm passing I then will get India,Iraq,Indonesia.....etc).But i'm getting nothing.This is my code
<body>
<div>
<div id="grid"></div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
schema: {
model:
{
id: "Id",
fields:
{
Id: { type: "number" },
Country: { type: "string", editable: true }
}
}
}
});
//filterable: true, $("#grid").kendoGrid({
dataSource: dataSource,
toolbar: ["create"],
sortable: true,
pageable: true,
refresh: true,
columns: [
{ field: "Country", title: "living country", width: 180, editor: AutocompleteCountry },
{ command: ["edit", "destroy"], title: " ", width: "250px" }
],
editable: "inline"
});
function AutocompleteCountry(container, options) {
debugger
$('<input id="autolist-country" data-text-field="Country" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoAutoComplete({
dataTextField: 'Country',
dataSource: {
transport: {
read: {
url: '/De
//data: {term:x}tails/GetCountries',
dataType: 'json'
},
filter: "contains" },
}
});
}
Now i'm getting my data from db like
public JsonResult GetCountries()
{
try
{
var countrylist = (from countries in detailsContext.Countrylists select countries.Country);
return Json(new { countrylist }, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
throw new ApplicationException("Error");
}
}