Dojo datagrid 和treegrid 帮助 - datagrid 有一个重组闪存吗?
我花了一些时间尝试让 Dojo 网格 (1.5) 发挥良好作用。具体来说,我花了大约两周的时间尝试实现一个网格,该网格允许我们的结果集数据折叠成行,其中可以扩展行。数据以 JSON 格式的全套形式出现,使用 ItemFileReadStore 作为存储。任何后续排序或分页都通过从应用程序获取新的 json 并在 url 中传入新的查询参数来处理。
嵌套数据只有两层深 - 始终显示的顶层和与顶层具有相同结构的子数据数组。每个节点都有一个唯一的 ID 和一个集群 ID - 在父节点上,唯一的 ID 和集群 ID 将匹配。
我最初对 TreeGrid 感到非常兴奋 - 但我不知道如何格式化它来执行我需要的操作 - 即消除“摘要行”和一行充满空单元格的额外行(???),我只是无法想象除非我将查询集中到一个集群,否则如何删除。我研究了测试示例,自己构建了许多测试页面,试图理解forestModel,据我所知,这是不必要的...我发现的文档很少,而且我在网上找到的资源暗示 TreeGrid 可能不可靠...
所以我决定尝试在 dataGrid 中实现可展开/可折叠的行。
我展平了 JSON 数据并添加了另一个属性来指示是顶级节点('alwaysShow' = true)。我以编程方式构建了网格并应用 grid.filter() 来仅拉出那些顶级节点。我通过扩展 ItemFileReadStore _FetchItems“过滤器”方法来修改该过滤器,以允许 OR 查询而不是 AND 查询,并且还修改了它以允许键指向数组 - 当顶级节点(单元格中的小 +/- 图标)时单击后,父节点的集群 ID 将添加到 grid.filter.allowed[] 中,并且更新过滤器,从而允许显示具有该 cluster_id 值的节点。
这在我的五个记录的小测试集上工作得很好(尽管我说有点缓慢......) - 但现在我从应用程序中拉回约 900 行,并且在扩展大型集群(约 80 行)时我看到滤镜更新时会出现很长的蓝色和白色闪烁。我花了一天的大部分时间试图在 firebug 中逐步找到它发生的位置,但是 dojo 逻辑是如此分散。似乎发生在调用 _Grid.js defaultUpdate 之前。
它太糟糕了,我正在考虑再次尝试使用 TreeGrid。我也在考虑用手来做这件事...我为自己花了这么多时间试图让 Dojo 开始工作而自责。如果有人有任何建议,我还会考虑商业“JSON->带有可折叠行的表”库...
有什么建议或见解吗?熟悉闪烁问题或者如何使 TreeGrid 适应我的需求?我知道这有点咆哮...非常感谢您的帮助。
-robbie
编辑:我最终放弃了尝试让 Dojo 做我需要的事情,并在不到一天的时间内自己编写了代码。这不是三周的最佳利用时间......
I'm having a bit of a time trying to get Dojo grids (1.5) to play nice. Specifically I've spent about two weeks of work trying to implement a grid that allows for our result set data to collapse into rows, where rows can be expanded. Data comes in as a full set in JSON format, using ItemFileReadStore as the store. Any subsequent sorts or pagings are handled by GETing a new json from the application, and passing in new query parameters in the url.
The nested data was only two layers deep - a top layer to always be displayed and an array of child data with identical structure as the top layer. Each node has a unique ID and a cluster ID - on a parent node the unique ID and cluster ID will match.
I was initially very excited with TreeGrid - but I couldn't see how I could format it to do what I needed - namely eliminate the 'summary row' and one extra row full of null cells (???) that I just couldnt figure out how to remove unless I focused the query to only one cluster. I studied the test examples, built many test pages myself, tried to understand the forestModel, which for what I could tell was unnecessary... I found so little documentation, and sources I found online hinted that TreeGrid might not be reliable...
So I decided I would try to implement the expandable/collapsible rows in dataGrid.
I flattened the JSON data and added another attribute to indicate being a top level node ('alwaysShow' = true). I built my grid programaticaly and applied grid.filter() to pull only those top level nodes. I modified that filter by extending the ItemFileReadStore _FetchItems "filter" method to allow for OR querying instead of AND, and also modified it to allow for keys to point to arrays - when a top level node (small +/- icon in the cell) is clicked, the cluster ID of the parent node is added to the grid.filter.allowed[] and the filter is updated, allowing nodes with that cluster_id value to be displayed.
This worked fine on my small test set of five records (although id say a little slugish...) - but now I am pulling ~900 rows back from the application, and on expanding large clusters (~80 rows) I am seeing a very long flash of blue and white on the filter updates. I've spent most of my day trying to step through in firebug to find where its happening, but the dojo logic is so spread out. Seems to be happening before the call to _Grid.js defaultUpdate.
Its so bad that I am considering trying again with TreeGrid. Im also considering just doing this by hand... Im kicking myself for spending so much time trying to get Dojo to work to begin with. I would also consider a commercial "JSON->table with collapsible row" library if anyone has any recommendations...
Any suggestions or insights? Familiarity with the flashing problem or how I could adapt TreeGrid to my needs? I'm aware this is a bit of a rant... Many thanks for any help.
-robbie
EDIT: I eventually gave up trying to get Dojo to do what I needed and coded it myself in less than a day. Not the best use of three weeks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
我刚刚找到了一个适合我的解决方案,我添加了以下 CSS:
.dojoxGridSummaryRow {
能见度:崩溃
}
基本上,摘要可能仍然会创建,但它们不可见,也不在表格布局中考虑。这对我有好处。希望这能解决您的问题。
这不会有帮助,只是让您知道:
“-但我不知道如何格式化它来执行我需要的操作 - 即消除“摘要行” “
这与我想要实现的目标完全相同,但没有找到解决方案,即使这看起来是一个非常简单的功能......如果我找到解决方案,我会告诉你......
EDIT:
I just found a solution that works for me, I have added the following CSS:
.dojoxGridSummaryRow {
visibility: collapse
}
Basically the summaries are probably still created but they are not visible nor taken into account in the table layout. That's good for me. Hope this will solve your issue.
This won't help but just to let you know that:
"- but I couldn't see how I could format it to do what I needed - namely eliminate the 'summary row' "
is the very EXACT same thing I'm trying to achieve and did not find the solution even though this looks like a very simple feature... Will let you know if I found a solution...