有没有办法在硬纸板外创建 'rallycard' 的实例?

Is there a way to create an instance of a 'rallycard' outside of a cardboard?

在文档中,关于 'rallycard' 对象,它指出:"In general, this class will not be created directly but instead will be instantiated by Rally.ui.cardboard.CardBoard as specified by its cardConfig"。我有一个功能模型,我想将它显示为像这样的卡片(如下),但它没有显示在呈现的页面中。

var card = Ext.create('Ext.Component', {
        style: {
            position: 'absolute',
            left: '100px', //left + 'px',
            top: '100px'//top + 'px'
        },
        items: [{
            xtype: 'rallycard',
            record: feature
        }],
        renderTo: Ext.getBody()
     });

     this.down('#main').add(card);

您是否收到控制台错误?我想除了卡片之外,可能还有一些其他必需的配置选项让您感到困惑。

另一个小提示,您不需要同时调用 renderTo 和调用 add。在这种情况下,我可能会放弃 renderTo。

我找到了一种方法来做到这一点。由于我在任何地方都没有看到示例,因此我将回答我自己的问题(下面的代码)。您必须为 objectId 找到一个有意义的值。

    Rally.data.ModelFactory.getModel({
        type: 'PortfolioItem/Feature',
        success: function(model) {
            var objectId = 1234; // <-- your objectId here
            model.load(objectId, {
                fetch: ['Name', 'State', 'Owner'],
                callback: function(result, operation) {
                    if(operation.wasSuccessful()) {
                        var owner = result.get('Owner');
                        console.log('owner', owner._refObjectName);

                        var card = Ext.create('Rally.ui.cardboard.Card', {
                            style: {
                                position: 'absolute',
                                left: '100px',
                                top: '200px',
                                width: '200px'
                            },
                            record: result
                        });
                        this.down('#main').add(card);
                    }
                },
                scope: this
            });
        },
        scope: this
    });