根据过滤字符串检查 TDataSet 行
我在内存 TDataSet 后代中使用 DevExpress TdxMemData 。 虽然它具有 Filtered: Boolean 和 Filter: String 属性,但它似乎实际上并没有自动对它们执行任何操作,而是依赖于 OnFilterRecord 事件的 Accept 参数的结果。
所以我正在寻找一种方法(可能在 TdxMemData 或 DevExpress 代码套件中的其他地方)来解析过滤器文本并将其应用到数据集。
理想情况下,我想要一种方法来针对过滤器测试单个行,看看它是否匹配,而不将其从数据集中过滤出来(我想突出显示与过滤器匹配的行)。
过滤字符串示例:
((Name = 'Jim') and (Rep > 1000)) or (Rep > 5000)
因此存在嵌套的 and 和 or 。 它实际上是由 DevExpress TcxDBFilterControl 构建的。
我真的希望我缺少一些简单的东西。
更新:我通过 DevExpress 打开了票证 看看他们是否支持某种解决方案。 我确实找到了他们的股票答案他们不支持过滤 关于 TdxMemData。
I am using a DevExpress TdxMemData in memory TDataSet descendant. While it has Filtered: Boolean and Filter: String properties, it doesn't appear to actually do anything with them automatically, instead relying on the result of the OnFilterRecord event's Accept parameter.
So what I am looking for is a way (maybe it is in TdxMemData or somewhere else in DevExpress's suite of code) to parse the filter text and apply it to the Dataset.
Ideally I would like a way to test an individual row against the filter to see if it matches without filtering it out of the dataset (I want to highlight rows that match the filter).
Example filter string:
((Name = 'Jim') and (Rep > 1000)) or (Rep > 5000)
So there is nested and's and or's. It is actually built by the DevExpress TcxDBFilterControl.
I am really hoping there is something simple I am missing.
Update: I opened a ticket with DevExpress to see if they support any kind of solution. I did find their stock answer that they don't support filtering on TdxMemData.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道这不是您寻找的答案,但 TdxMemData 数据集不支持过滤字符串。 要使用过滤器,请编写您自己的 OnFilterRecord 事件或将 ProgrammedFilter 设置为 true 并使用已过滤的记录列表(在运行时)填充 FilterList。
一种可能性是编写您自己的解析器来将过滤器字符串与 OnFilterRecord 事件中的当前记录进行比较。
I know this is not the answer your looking for, but the TdxMemData dataset does not support filter strings. To use filters either code your own OnFilterRecord event or set ProgrammedFilter to true and populate the FilterList with a list of the records which are filtered (at runtime).
One possibility would be to code your own parser to compare the filter string against the current record in the OnFilterRecord event.
您可能需要考虑将 TdxMemData 替换为 TkbmMemTable。 它是免费的,工作原理与 DX 组件类似,并且支持过滤字符串。 与在 OnFilterRecord 中实现过滤器字符串解析器相比,移植所花费的时间可能要少得多! 它可以毫无问题地与其他 DX 组件一起使用。
You might want to look at replacing the TdxMemData with TkbmMemTable. It's free, works similarly to the DX component, and supports filter strings. Would likely take a lot less time to port over than it would to implement a filter string parser in OnFilterRecord! It'll work with the other DX components without problems.
您要寻找的不是过滤数据,而是在满足条件时以不同方式显示数据的问题。 如果您使用 TDBGrid 来显示数据,请查看 TDBGrid 上的 DrawColumnCell() 事件:
由于您使用的是 TdxMemData,因此您可能也在使用 DevEx 网格。 它必须有类似的方式来执行默认绘图以外的操作; 您可以在那里使用类似的技术。 (我已经有几年没有使用 DevEx 的东西了;当前的雇主不喜欢它们,因此不会支付这笔费用。:-( )
What you're looking for is not filtering the data, but a matter of displaying it differently if it meets a condition. If you're using a TDBGrid to display the data, look into the DrawColumnCell() event on the TDBGrid:
Since you're using TdxMemData, you're probably using the DevEx grid, too. It has to have a similar way to do something other than the default drawing; you can use a similar technique there. (I haven't used the DevEx stuff in a few years; current employer doesn't like them, and therefore won't spring for the expense. :-( )