关于wijmo清除筛选条件的问题
请问一下,我用ajax返回新的数据源想在表格中显示,因为更换了数据源,所有我想清除掉原来表格中数据源的所有筛选条件,有什么方法吗您好,wijmo的筛选是在数据源中定义的,只需要给filter的回调设置返回true即可,参考示例:
https://demo.grapecity.com.cn/wijmo/demos/Core/CollectionView/CreatingViews/Filtering/Overview/purejs 但是表头里的筛选按钮有办法重置吗?我看还是会有筛选条件,虽然表格里的数据是不筛选了 您好,Grid本身带的筛选器,可以调用筛选器的clear方法来清空筛选设置,参考API:
https://demo.grapecity.com.cn/wijmo/api/classes/wijmo_grid_filter.flexgridfilter.html#clear
示例如下:
1、app.js
import 'bootstrap.css';
import '@grapecity/wijmo.styles/wijmo.css';
import './styles.css';
import * as wjGrid from '@grapecity/wijmo.grid';
import * as wjGridFilter from '@grapecity/wijmo.grid.filter';
//
document.readyState === 'complete' ? init() : window.onload = init;
//
function init() {
//
// generate some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = [];
for (var i = 0; i < 2000; i++) {
data.push({
id: i,
country: countries,
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000,
});
}
//
// FlexGridFilter client-side filtering
var theGrid = new wjGrid.FlexGrid('#theGrid', {
itemsSource: data,
});
var filter = new wjGridFilter.FlexGridFilter(theGrid);
document.getElementById("btn").addEventListener("click",function(){
filter.clear();
});
}
2、inde.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>GrapeCity Wijmo FlexGrid Excel-like Filter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SystemJS -->
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('./src/app');
</script>
</head>
<body>
<button id="btn">按钮</button>
<div class="container-fluid">
<div id="theGrid">
</div>
</div>
</body>
</html>
测试地址:
https://demo.grapecity.com.cn/wijmo/demos/Grid/FilteringSearching/Excel-likeFilter/Overview/purejs KevinChen 发表于 2020-11-11 15:57
您好,Grid本身带的筛选器,可以调用筛选器的clear方法来清空筛选设置,参考API:
https://demo.grapecity ...
好的 已解决 感谢 不客气,感谢反馈,本贴结帖了,有新的问题欢迎发新帖交流~
页:
[1]