过滤dojo中的详细记录

发布于 2024-10-08 19:35:33 字数 335 浏览 0 评论 0原文

我有一个包含 dijit.Tree 和 dojox.grid.EnhancedGrid 的页面,两者都连接到 ItemFileWriteStore 中的一些分层数据。当用户单击树中的某个项目时,我希望能够仅显示网格中该项目的直接子项目及其属性。这是数据库应用程序中相当常见的模式,但我找不到任何这样的示例,或者也许我找错了地方。

查看网格文档,我在 DataGrid 上看到了 setQuery 方法。但是,查看 ItemFileReadStore 的查询语法,我没有看到任何可以让我指定仅获取给定项目的子项的内容。我缺少什么吗,还有其他方法可以做到这一点吗?

使用道场1.5。

(为了清晰起见进行了编辑)

I have a page with a dijit.Tree, and a dojox.grid.EnhancedGrid both hooked up to some hierarchical data in an ItemFileWriteStore. When the user clicks on an item in the tree, I want to be able to show only the immediate children of that item in the grid, along with their attributes. This is a rather common pattern in database applications, but I can't find any examples of this, or perhaps I'm looking in the wrong place.

Looking at the grid docs, I see a setQuery method on the DataGrid. However, looking at the query syntax for ItemFileReadStore, I don't see anything that would let me specify to fetch only the children of a given item. Is there something I'm missing, is there another way to do this?

Using dojo 1.5.

(Edited for clarity)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终难愈 2024-10-15 19:35:33

好吧,既然没有人回答,我就想出了自己的解决方案。我认为这应该是 DataStore 框架中内置的内容,因此我在 ItemFileReadStore 中找到了一个适当的方法来挂钩,并对其进行了扩展以添加一些查询选项以允许详细查询。

以下代码添加两个可用的 QueryOptions 参数(parentItem、parentAttribute),它们指定用于详细向下钻取查询的父项和父属性。它们与“深度”选项不兼容,因为这两者组合的预期结果尚不清楚。

        dojo.extend(dojo.data.ItemFileReadStore, {
        _getItemsArray: function(/*object?*/queryOptions) {
            if (queryOptions) {
                if (queryOptions.deep && queryOptions.parentItem) {
                    throw "Invalid query: a drill-down search can not be 'deep'"
                }
                if (queryOptions.deep) {
                    return this._arrayOfAllItems;
                }
                if (queryOptions.parentItem) {
                    if (!queryOptions.parentAttribute) {
                        throw "Invalid query: an attribute is required for drill-down searches.";
                    }
                    return this.getValues(queryOptions.parentItem,queryOptions.parentAttribute);
                }
            }
            return this._arrayOfTopLevelItems;
        }

    });

上述代码可供任何人使用。

Well, since no one answered, I came up with my own solution. I figured that this should be something that should have been built in to the DataStore framework, so I found an appropriate method in ItemFileReadStore to hook into, and extended it to add some query options to allow detail queries.

The following code adds two available QueryOptions arguments (parentItem, parentAttribute) which specify a parent item and a parent attribute for detail drill-down queries. They aren't compatible with the 'deep' option as the expected result of a combination of those two isn't clear.

        dojo.extend(dojo.data.ItemFileReadStore, {
        _getItemsArray: function(/*object?*/queryOptions) {
            if (queryOptions) {
                if (queryOptions.deep && queryOptions.parentItem) {
                    throw "Invalid query: a drill-down search can not be 'deep'"
                }
                if (queryOptions.deep) {
                    return this._arrayOfAllItems;
                }
                if (queryOptions.parentItem) {
                    if (!queryOptions.parentAttribute) {
                        throw "Invalid query: an attribute is required for drill-down searches.";
                    }
                    return this.getValues(queryOptions.parentItem,queryOptions.parentAttribute);
                }
            }
            return this._arrayOfTopLevelItems;
        }

    });

The above code is available for anyone to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文