如何在网格上添加自定义按钮并传递行值? [英] How to add a custom button on grid and pass row values?

查看:27
本文介绍了如何在网格上添加自定义按钮并传递行值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向网格添加一个按钮,以便用户可以通过传入按钮行中的值来查看给定任务的时间表条目值.网格加载得很好,直到我将按钮添加到 columnCfgs.当按钮在那里时,我收到未捕获的类型错误:对象 [对象对象] 没有方法 'setSortState'"错误.

I would like to add a button to a grid so the user can see the time sheet entry values for a given task by passing in the values from the button's row. The grid loads just fine until I add the button to columnCfgs. When the button is there I get a "Uncaught TypeError: Object [object Object] has no method 'setSortState'" error.

    {text:'View Time',
        xtype: 'button',
        listeners: {
            click: Ext.bind(this._viewTimeEntryValues(projectId, taskId), this)
        }
    },

完整的网格代码:

this.grid = this.add({
    xtype: 'rallygrid',
    model: model,
    defaultSortToRank: true,
    showRowActionsColumn: false,
    columnCfgs: [
        {text:'View Time',
            xtype: 'button',
            listeners: {
                click: Ext.bind(this._viewTimeEntryValues(projectId, taskId), this)
            }
        },
        {text:'Id',             dataIndex:'FormattedID'},
        {text:'Name',           dataIndex:'Name'},
        {text:'Project',        dataIndex:'Project'}
    ],
    storeConfig: {
        context: {
            projectScopeUp: false,
            projectScopeDown: true
        },
        filters: this._activeFilters
    }
});

  • 如何向网格添加自定义按钮?
  • 如何从按钮的行中传递值?
  • 推荐答案

    我在 这个 github 仓库.这是带有按钮的网格:

    I used a button in code in this github repo. Here is grid with a button:

    var g = Ext.create('Rally.ui.grid.Grid', {
        id: 'g',
        store: store,
        enableRanking: true,
        columnCfgs: [
              {text: 'Formatted ID', dataIndex: 'FormattedID'},
              {text: 'Name', dataIndex: 'Name'},
              {text: 'State', dataIndex: 'State'},
              {text: 'Last Revision',
                renderer: function (v, m, r) {
                    var id = Ext.id();
                    Ext.defer(function () {
                        Ext.widget('button', {
                            renderTo: id,
                            text: 'see',
                            width: 50,
                            handler: function () {
                                that._getRevisionHistory(data, r.data);
                            }
                        });
                    }, 50);
                return Ext.String.format('<div id="{0}"></div>', id);
                }
    
            }
       ],
       height: 400,
    });
    

    这篇关于如何在网格上添加自定义按钮并传递行值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆