Rallygrid上的工具提示

时间:2015-11-24 23:05:12

标签: tooltip rally

我正在寻找一个向拉力赛网格实施自定义工具提示的示例。我试图在列上使用渲染器配置,但到目前为止还没有运气。有没有人有一个有效的例子?

谢谢!

1 个答案:

答案 0 :(得分:2)

更新:为了确保工具提示的正确时间和删除,我在工具提示上调用showNow()方法并使用其destroyAfterHide配置属性

    listeners: {
        itemmouseenter: function(g, record, item, index, e, eOpts) {
            console.log(record.get('FormattedID'));
            Ext.create('Rally.ui.tooltip.ToolTip', {
                target : item,
                destroyAfterHide: true,
                hideDelay: 0,
                html: '<p><strong>This is a tooltip: ' + record.get('FormattedID') + '</strong></p>'
            }).showNow();

以下是使用Rally.ui.tooltip.Tooltip和rallygrid的完整示例示例:

enter image description here

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
    Ext.create('Rally.data.wsapi.Store', {
        model: 'userstory',
        autoLoad: true,
        listeners: {
            load: this._onDataLoaded,
            scope: this
        },
        fetch: ['FormattedID', 'Name', 'ScheduleState', 'Tasks', 'Defects']
    });
},
_onDataLoaded: function(store, data) {
    var records = _.map(data, function(record) {
        return Ext.apply({
            TaskCount: record.get('Tasks').Count
        }, record.getData());
    });

    this.add({
        xtype: 'rallygrid',
        showPagingToolbar: false,
        editable: true,
        store: Ext.create('Rally.data.custom.Store', {
            data: records
        }),
        listeners: {
            itemmouseenter: function(g, record, item, index, e, eOpts) {
                console.log(record.get('FormattedID'));
                Ext.create('Rally.ui.tooltip.ToolTip', {
                    target : item,
                    destroyAfterHide: true,
                    hideDelay: 0,
                    html: '<p><strong>This is a tooltip: ' + record.get('FormattedID') + '</strong></p>'
                }).showNow();
            },
            select: this.getRecordOnSelectedRow,
            load : function(g, record, index, options){
                this.getRecordOnSelectedRow(g, record, 0, options);
            },
            scope: this
        },
        columnCfgs: [
            {
                xtype: 'templatecolumn',
                text: 'ID',
                dataIndex: 'FormattedID',
                width: 100,
                tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
            },
            {
                text: 'Name',
                dataIndex: 'Name'
            },
            {
                text: 'Schedule State',
                dataIndex: 'ScheduleState',
            },
            {
                text: '# of Tasks',
                dataIndex: 'TaskCount',
            },
            {
                text: '# of Defects',
                dataIndex: 'Defects',
                renderer: function(value) {
                    return value.Count;
                }
            }
        ]
    });
},
getRecordOnSelectedRow:function(g, record, rowIndex, options){
    console.log(record);
}

});