Web服务的Kendo UI自动完成功能无法正常工作

时间:2014-05-29 10:25:05

标签: jquery asp.net-mvc-3 kendo-ui

我是KendoUI的新手。我正在开发KendoUI自动完成功能并根据输入的文本获取Citynames。但我想在方法中将文本框值作为请求对象传递。下面是我的Jquery和Webservice的代码。如何在GetArea方法中将控制值作为请求对象传递。

在Html页面中调用:

   $.addressKendoAutoComplete({
            city: "#City",
            county: "#County",
            region: "#Region",
            url: "/UKPostCode/GetArea"
        });

Jquery方法:

 $.extend({addressKendoAutoComplete: function (operation) {

    $(operation.city).kendoAutoComplete({
        minLength: 2,
        dataTextField: "city",
        dataSource: function (request, response) {
          return  new kendo.data.DataSource({
                transport: {
                    read: {
                        url: operation.url,
                        dataType: "json"
                    }
                },
                schema: {
                    errors: function (e) {
                        return e;
                    },
                    parse: function (data) {
                        return data.Name;
                    }
                }
            }
           );
        }
    });


}

});

Webservice方法:

   public JsonResult GetArea()
    {
        string region = Request["region"];
        string city = Request["city"];
        string county = Request["county"];
        string postcode = Request["postcode"];

        List<UKPostCodeInfo> result = new List<UKPostCodeInfo>();
        result = UkPostCodeController.GetPostCode(region, county, city, postcode);

        return Json(result, JsonRequestBehavior.AllowGet);
    }

0 个答案:

没有答案