gpt4 book ai didi

javascript - 如何从kendo dataSource获取原始数据?

转载 作者:行者123 更新时间:2023-12-03 07:19:38 24 4
gpt4 key购买 nike

我从后端获取剑道网格数据并将其设置为剑道网格选项alignedProcessesToRiskGridOptions 现在数据显示在网格中,但我也想获取原始数据来编写一些逻辑,我如何从数据源获取数据或直接调用 RiskService AngularJs 工厂和将其分配给var gridData

ctrl.js

   $scope.alignedProcessesToRiskGridOptions = RiskService.alignedProcessToRiskGrid();
$scope.alignedProcessesToRiskGridOptions.dataSource = RiskService.getAlignedProcessesToRiskGridDataSource($stateParams.riskId);
gridData = $scope.alignedProcessesToRiskGridOptions.dataSource.data();
console.log('RISK DATA', gridData);

工厂.js

getAlignedProcessesToRiskGridDataSource: function(riskKey) {
var countNew = 0;
return new kendo.data.DataSource({
type: 'json',
serverPaging: true,
serverSorting: true,
serverFiltering: true,
transport: {
read: function(options) {
var gridSearchObject = {
skip: options.data.skip,
take: options.data.take,
pageSize: options.data.pageSize,
page: options.data.page,
sorting: options.data.sort,
filter: options.data.filter
};
return $http.post(
'app/risk/rest/allAlignedProcessesToRisk/' + riskKey, gridSearchObject).success(
function(data) {
countNew = data.totalCount;
options.success(data.resultDTOList);
});
}

},

最佳答案

根据kendo文档,至少有几种方法可以从数据源获取实际数据。

There is the view method

Returns the data items which correspond to the current page, filter, sort and group configuration. Compare with the data method, which will return data items from all pages, if local data binding and paging are used.

There is the data method

Gets or sets the data items of the data source.

If the data source is bound to a remote service (via the transport option) the data method will return the service response. Every item from the response is wrapped in a kendo.data.ObservableObject or kendo.data.Model (if the schema.model option is set).

If the data source is bound to a JavaScript array (via the data option) the data method will return the items of that array. Every item from the array is wrapped in a kendo.data.ObservableObject or kendo.data.Model (if the schema.model option is set).

由于您使用的是 data 方法,因此您应该能够通过结果对象的属性和方法访问数据。

您应该能够通过 console.log(gridData.length) 检查 gridDatalength,以及检查任何单个对象通过数组索引 console.log(gridData[0]) 在数据中。此外,您应该能够通过 console.log(gridData[0].firstProperty) 检查对象的属性。

如果这些都不起作用,则可能是因为未使用 queryfetch 的上下文检查数据源。如果你check out this example ,您将看到正在 fetch 函数内部评估数据。

您可以找到有关 the Kendo DataSource in their online documentation 的更多信息.

最后,您可以在 this question about the kendo grid 中看到我使用 Kendo 数据源的不同方式的示例。 .

关于javascript - 如何从kendo dataSource获取原始数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36264603/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com