gpt4 book ai didi

kendo-ui - 你如何使用过滤器循环遍历剑道 UI 网格中的所有行

转载 作者:行者123 更新时间:2023-12-03 11:24:06 25 4
gpt4 key购买 nike

这是我的代码。它有效,如果你想遍历所有行。现在,QA 告诉我我必须让它支持过滤器。因此,当用户使用过滤器时,网格上只会显示行的一个子集。我只需要遍历那些行。

    var entityGrid = $("#EntitesGrid").data("kendoGrid");       
var data = entityGrid.dataSource.data();
var totalNumber = data.length;

for(var i = 0; i<totalNumber; i++) {
var currentDataItem = data[i];
VersionIdArray[i] = currentDataItem.VersionId;
}

我试过。

    var data = entityGrid.dataSource.data().fetch();



    var data = entityGrid.dataSource.data().filter();

无法让它工作。

最佳答案

为了将来引用和感兴趣的人,我在以下位置找到了解决方案:

http://colinmackay.scot/2012/07/23/kendo-ui-paging-and-accessing-the-filtered-results-in-javascript/

It works by first getting hold of the grid's data source, getting the filter and the data, creating a new query with the data and applying the filter to it. While this does result in getting the results of the filter it does have the distinct disadvantage of processing the filter operation twice.


function displayFilterResults() {
// Gets the data source from the grid.
var dataSource = $("#MyGrid").data("kendoGrid").dataSource;

// Gets the filter from the dataSource
var filters = dataSource.filter();

// Gets the full set of data from the data source
var allData = dataSource.data();

// Applies the filter to the data
var query = new kendo.data.Query(allData);
var filteredData = query.filter(filters).data;

// Output the results
$('#FilterCount').html(filteredData.length);
$('#TotalCount').html(allData.length);
$('#FilterResults').html('');
$.each(filteredData, function(index, item){
$('#FilterResults').append('<li>'+item.Site+' : '+item.Visitors+'</li>')
});
}

关于kendo-ui - 你如何使用过滤器循环遍历剑道 UI 网格中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13017632/

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