请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

zx0730

注册会员

6

主题

11

帖子

132

积分

注册会员

积分
132
zx0730
注册会员   /  发表于:2020-11-11 11:14  /   查看:2834  /  回复:5
请问一下,我用ajax返回新的数据源想在表格中显示,因为更换了数据源,所有我想清除掉原来表格中数据源的所有筛选条件,有什么方法吗

5 个回复

倒序浏览
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-11-11 11:25:42
沙发
您好,wijmo的筛选是在数据源中定义的,只需要给filter的回调设置返回true即可,参考示例:
https://demo.grapecity.com.cn/wi ... ing/Overview/purejs
回复 使用道具 举报
zx0730
注册会员   /  发表于:2020-11-11 13:28:24
板凳
但是表头里的筛选按钮有办法重置吗?我看还是会有筛选条件,虽然表格里的数据是不筛选了
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-11-11 15:57:45
地板
您好,Grid本身带的筛选器,可以调用筛选器的clear方法来清空筛选设置,参考API:
https://demo.grapecity.com.cn/wi ... idfilter.html#clear

示例如下:

1、app.js
  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. import * as wjGrid from '@grapecity/wijmo.grid';
  5. import * as wjGridFilter from '@grapecity/wijmo.grid.filter';
  6. //
  7. document.readyState === 'complete' ? init() : window.onload = init;
  8. //
  9. function init() {
  10.     //
  11.     // generate some random data
  12.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = [];
  13.     for (var i = 0; i < 2000; i++) {
  14.         data.push({
  15.             id: i,
  16.             country: countries[i % countries.length],
  17.             downloads: Math.round(Math.random() * 20000),
  18.             sales: Math.random() * 10000,
  19.             expenses: Math.random() * 5000,
  20.         });
  21.     }
  22.     //
  23.     // FlexGridFilter client-side filtering
  24.     var theGrid = new wjGrid.FlexGrid('#theGrid', {
  25.         itemsSource: data,
  26.     });
  27.     var filter = new wjGridFilter.FlexGridFilter(theGrid);

  28.     document.getElementById("btn").addEventListener("click",function(){
  29.         filter.clear();
  30.     });
  31. }
复制代码


2、inde.html
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <title>GrapeCity Wijmo FlexGrid Excel-like Filter</title>
  7.     <meta name="viewport" content="width=device-width, initial-scale=1.0">

  8.     <!-- SystemJS -->
  9.     <script src="node_modules/systemjs/dist/system.src.js"></script>
  10.     <script src="systemjs.config.js"></script>
  11.     <script>
  12.         System.import('./src/app');
  13.     </script>
  14. </head>
  15. <body>
  16.     <button id="btn">按钮</button>
  17.     <div class="container-fluid">
  18.       <div id="theGrid">
  19.       </div>
  20.     </div>

  21. </body>
  22. </html>
复制代码


测试地址:
https://demo.grapecity.com.cn/wi ... ter/Overview/purejs
回复 使用道具 举报
zx0730
注册会员   /  发表于:2020-11-11 16:06:34
5#
KevinChen 发表于 2020-11-11 15:57
您好,Grid本身带的筛选器,可以调用筛选器的clear方法来清空筛选设置,参考API:
https://demo.grapecity ...

好的 已解决 感谢
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-11-11 17:00:25
6#
不客气,感谢反馈,本贴结帖了,有新的问题欢迎发新帖交流~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部