使用服务器端数据源时标题复选框选择不起作用 [英] Header checkbox selection doesn't work when using Server Side Data source

查看:49
本文介绍了使用服务器端数据源时标题复选框选择不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所暗示的,我将 ag-grid 与 Angular 一起使用,并且我使用了一个自定义类,该类实现了 IServerSideDatasource,用于从 API 获取数据,并将 rowModelType 设置为serverSide".

As the title suggests, i'm using ag-grid with Angular, and i use a custom class that implements IServerSideDatasource for fetching data from API with rowModelType set to 'serverSide'.

问题是,当我将 headerCheckboxSelection 和 checkboxSelection 设置为 true 时,复选框选择出现在每一行旁边,但它没有出现在标题中,而当我使用客户端行模型类型时它工作得很好.

The problem is that when i set headerCheckboxSelection and checkboxSelection to true, checkbox select appears next to each row but it doesn't appear in the Header, whereas it works perfectly fine when i use Client Side Row Model type.

有人可以帮忙吗?

推荐答案

标题复选框选择不是 ag-grid 的服务器端行模型支持的功能.您应该会收到一条控制台日志消息,通知您这一点.

Header checkbox selection is not a supported feature of ag-grid's Server Side row model. You should be getting a console log message notifying you of this.

请参阅文档了解更多信息.

Feature                     Client-side   Infinite    Server-side     Viewport
...
Row Selection               ✔             ✔            ✔              ✔
Header Checkbox Selection   ✔             ✕            ✕              ✕

如果您想实现此功能,您将需要使用自定义标头组件手动处理此功能.我以前做过(尽管使用的是无限行模型,而不是服务器端),但是您需要跟踪一些事情...

If you want to implement this functionality, you will need to manually handle this functionality using a custom header component. I've done it before (albeit, using Infinite Row-Model, not Server-side), but you need to keep track of a few things...

  • 当前检查的总行列表.
  • 是否选择了全部检查"?
  • 是否显示不确定的复选框(选择了一些行,但不是所有行).
  • 从服务器获取行时,您需要查看是否已按下检查所有按钮并相应地更新该行的选择.

我使用了一个 Angular 服务来保持一个中心位置来跟踪所有这些信息,并且只依靠标题组件来显示复选框.

I used an Angular Service to keep a central location for tracking all this information, and just relied on the header-component for displaying the checkbox.

如您所见,这是一项艰巨的任务,没有简单的解决方案.

As you see, it is a non-trivial task, and there is no easy solution.

这篇关于使用服务器端数据源时标题复选框选择不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆