如何在 kendo 下拉列表中分配跳过和取值
How to assign skip and take value in kendo dropdown
我需要将大量数据填充到 kendo 下拉列表中(可能达到数百万)。所以我正在尝试使用 kendo 的 serverFiltering
来实现这一点。我在 github 中检查了他们的官方 api,他们使用的参数是 skip
和 take
,这对他们来说似乎工作正常。我正在尝试发送跳过并通过以下代码
$("#parentProductId").kendoDropDownList({
filter: "startswith",
dataTextField: "ProductName",
dataValueField: "id",
optionLabel: ' --Select--',
dataSource: {
serverFiltering: true,
data: {
skip:0 ,
take: 10
},
transport: {
read: {
url: webApiUri + '/Product/ProductSel',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
}
}
}
}
});
我的Apicontroller如下:-
[Route("api/Product/ProductSel")]
public List<SpProductSel_Result> ProductGet(int skip, int take)
{
//return result
}
现在我的问题是这个 api 控制器没有被调用。我在这里做错了什么?
其中一种可能是您需要使用正确的 transport.read 配置。使用传输配置时,我们将数据指定为读取的一部分,请参阅代码片段 below.Refer 至 kendo 文档 transport.read.data
示例 #1 发送附加参数 作为对象
transport: {
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: "html5" // send "html5" as the "q" parameter , like int skip and take
}
}
示例 # 2 - 通过从函数返回参数来发送附加参数
transport: {
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: function() {
return {
skip: 0, // send 0 as the "skip" parameter
take:10 // send 10 as the "take" parameter
};
}
}
}
我需要将大量数据填充到 kendo 下拉列表中(可能达到数百万)。所以我正在尝试使用 kendo 的 serverFiltering
来实现这一点。我在 github 中检查了他们的官方 api,他们使用的参数是 skip
和 take
,这对他们来说似乎工作正常。我正在尝试发送跳过并通过以下代码
$("#parentProductId").kendoDropDownList({
filter: "startswith",
dataTextField: "ProductName",
dataValueField: "id",
optionLabel: ' --Select--',
dataSource: {
serverFiltering: true,
data: {
skip:0 ,
take: 10
},
transport: {
read: {
url: webApiUri + '/Product/ProductSel',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
}
}
}
}
});
我的Apicontroller如下:-
[Route("api/Product/ProductSel")]
public List<SpProductSel_Result> ProductGet(int skip, int take)
{
//return result
}
现在我的问题是这个 api 控制器没有被调用。我在这里做错了什么?
其中一种可能是您需要使用正确的 transport.read 配置。使用传输配置时,我们将数据指定为读取的一部分,请参阅代码片段 below.Refer 至 kendo 文档 transport.read.data
示例 #1 发送附加参数 作为对象
transport: {
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: "html5" // send "html5" as the "q" parameter , like int skip and take
}
}
示例 # 2 - 通过从函数返回参数来发送附加参数
transport: {
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: function() {
return {
skip: 0, // send 0 as the "skip" parameter
take:10 // send 10 as the "take" parameter
};
}
}
}