剑道网格-传输读取没有从输入框中获得搜索条件



我有你的基本剑道网格,和一个文本输入框。我只是想在单击#searchButton后将框中的内容传递给传输读取器。我就是这么做的。警报显示该值在那里,但在网格读取中的"id"中没有拾取到它。我做错了什么?

$("#searchButton").on("click", function () {
    alert($("#searchCriteria").val());
    $($asGrid).data('kendoGrid').dataSource.read();
});
var asGridDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "/api/securitiesapi",
            data: {
                id: $("#searchCriteria").val() 
            }
        }
    },
    schema: {
        model: {
            id: "ID",
            fields: {
                CUSIP: { editable: false },
                SecurityType: { editable: false },
                PoolNumber: { editable: false },
                PoolPrefix: { editable: false },
                IssueDate: { editable: false },
                MaturityDate: { editable: false },
                OriginalBalance: { editable: false },
            }
        }
    }
});

这是直接取自剑道文档页面的网格:

read: {
  url: "http://demos.telerik.com/kendo-ui/service/twitter/search",
  dataType: "jsonp", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
  data: {
    q: $("#search").val() // send the value of the #search input to the remote service
  }
}

我在做同样的事情,但它就是不起作用。

他们的文档要么是错误的,要么是误导的。要使它按照您的意愿工作,您应该将data属性更改为一个函数,如下所示:

transport: {
  read: {
    url: "/api/securitiesapi",
    data: function() {
      return { id: $("#searchCriteria").val() };
    }
  }
}

最新更新