Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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


C#
public JsonResult GetCountries()
{
    try
    {
        var countrylist = (from countries in detailsContext.Countrylists select countries.Country); // here i'm getting all my db values
        return Json(new { countrylist }, JsonRequestBehavior.AllowGet);
    }
    catch (Exception)
    {
        throw new ApplicationException("Error");
    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900