Is it possible to check the visibility of the particular datatable row?
是否可以检查特定数据行的可见性?
I found only isColumnVisible
and getVisibleCount
, but both of them are irrelevant and as far as I can see, there's no such solution for the rows.
我只发现了isColumnVisible和getVisibleCount,但它们都是无关的,而且据我所知,这些行没有这样的解决方案。
How can I do such thing? For instance, after the filtering I can get all data items, but that's all. It's the only idea I've come up with:
我怎么能做这样的事?例如,在过滤之后,我可以得到所有的数据项,但仅此而已。这是我想到的唯一的想法:
onAfterFilter:function(){
var dataId = this.data.pull;
var keys = Object.keys(dataId);
for (var i = 0; i < keys.length; i++){
console.log(this)
}
}
http://webix.com/snippet/c6ecdcd5
http://webix.com/snippet/c6ecdcd5
3 个解决方案
#1
1
Ok it feels like a long way of doing this. And I've not done anything other than just get it to work.
好吧,这是很长的一段路。除了让它工作之外,我什么都没做。
But you will find all of the ids you need in this.data.order
so the following code puts all the filtered items into filteredObjs
但是,您将在这个.data中找到所需的所有id。这样,下面的代码将所有过滤后的项放入filteredObjs中。
var dataId = this.data.pull;
var keys = Object.keys(dataId);
var filteredIds = this.data.order;
var filteredObjs = [];
for (var i = 0; i < filteredIds.length; i++) {
for (var j = 0; j < keys.length; j++) {
if (filteredIds[i] === dataId[keys[j]].id) {
filteredObjs.push(dataId[keys[j]]);
}
}
}
console.log(filteredObjs);
Not saying its perfect. But its a start...
不是说它的完美。但它的一个开始…
#2
0
For starters you need to change console.log(this)
to console.log(keys[i])
对于初学者,您需要更改console.log(this)到console.log(keys[i])
#3
0
As an alternative to the data-based solution made by @ShaunParsons I found that it's possible to check the visibility through the getItemNode
function, as the nodes of the invisible items are undefined
.
作为由@ShaunParsons所做的基于数据的解决方案的替代方案,我发现可以通过getItemNode函数检查可见性,因为无形项的节点是未定义的。
http://webix.com/snippet/4f31a5b5
http://webix.com/snippet/4f31a5b5
onAfterFilter:function(){
var dataId = this.data.pull;
var keys = Object.keys(dataId);
for (var j = 0; j < keys.length; j++) {
console.log(this.getItemNode(keys[j]))
}
}
#1
1
Ok it feels like a long way of doing this. And I've not done anything other than just get it to work.
好吧,这是很长的一段路。除了让它工作之外,我什么都没做。
But you will find all of the ids you need in this.data.order
so the following code puts all the filtered items into filteredObjs
但是,您将在这个.data中找到所需的所有id。这样,下面的代码将所有过滤后的项放入filteredObjs中。
var dataId = this.data.pull;
var keys = Object.keys(dataId);
var filteredIds = this.data.order;
var filteredObjs = [];
for (var i = 0; i < filteredIds.length; i++) {
for (var j = 0; j < keys.length; j++) {
if (filteredIds[i] === dataId[keys[j]].id) {
filteredObjs.push(dataId[keys[j]]);
}
}
}
console.log(filteredObjs);
Not saying its perfect. But its a start...
不是说它的完美。但它的一个开始…
#2
0
For starters you need to change console.log(this)
to console.log(keys[i])
对于初学者,您需要更改console.log(this)到console.log(keys[i])
#3
0
As an alternative to the data-based solution made by @ShaunParsons I found that it's possible to check the visibility through the getItemNode
function, as the nodes of the invisible items are undefined
.
作为由@ShaunParsons所做的基于数据的解决方案的替代方案,我发现可以通过getItemNode函数检查可见性,因为无形项的节点是未定义的。
http://webix.com/snippet/4f31a5b5
http://webix.com/snippet/4f31a5b5
onAfterFilter:function(){
var dataId = this.data.pull;
var keys = Object.keys(dataId);
for (var j = 0; j < keys.length; j++) {
console.log(this.getItemNode(keys[j]))
}
}