Dojo dgrid OnDemandList中的小部件

时间:2013-07-10 22:38:31

标签: dojo dgrid

我正在尝试执行与this question类似的操作,但使用的是OnDemandList而不是OnDemandGrid。

这是我到目前为止所拥有的

define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dgrid/OnDemandList",
    "widget/CategoryItem",
    "dojo/dom-construct",
    "dojo/text!./templates/category-list.html"
], function(declare, _Widget, _TemplatedMixin, _WidgetsInTemplateMixin, OnDemandList, CategoryItem, domConstruct, template) {
    var CatList = declare([OnDemandList]);
    return declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], {
        templateString: template,
        baseClass: "category-list",

        postCreate: function() {
            this.inherited(arguments);

            // Create OnDemandList, place in div defined in template.
            var cat1 = this.cat1 = new CatList({
                store: this.store,
                renderRow: this.renderItem
            }, this.categoriesLevel0);

        },

        renderItem: function(item) {
            return new CategoryItem({
                title: item.title
            });
        }
    });
});

问题是我的renderItems函数需要以某种方式返回包含我的自定义小部件的dom。现在我收到此错误Error on domReady callback: Error: NotFoundError: DOM Exception 8

1 个答案:

答案 0 :(得分:2)

是的,它肯定需要从renderRow返回一个dom节点。假设您正在为CategoryItem使用_WidgetBase,它应该像:

renderItem: function(item) {
    var category = new CategoryItem({
        title: item.title
    });
    return category.domNode;
}

这里的示例:https://github.com/SitePen/dgrid/wiki/OnDemandList-and-OnDemandGrid几乎完全相同,除了它使用put-selector,它只是构造一个div,将小部件附加到它并返回新的div。

相关问题