Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS4-工具提示不显示列值_Javascript_Extjs_Extjs4 - Fatal编程技术网

Javascript ExtJS4-工具提示不显示列值

Javascript ExtJS4-工具提示不显示列值,javascript,extjs,extjs4,Javascript,Extjs,Extjs4,我试图为网格中的每一列编写一个特定的工具提示 我当前的实现无法获取悬停在上面的记录的值。如何引用行条目的特定列/行值 代码 Ext.onReady(function() { var trackStore = new Ext.data.Store({ storeId: 'soundCloudStore', proxy: { type: 'memory', data: [ { title: 'Test', durati

我试图为网格中的每一列编写一个特定的工具提示

我当前的实现无法获取悬停在上面的记录的值。如何引用行条目的特定列/行值

代码

Ext.onReady(function() {
var trackStore = new Ext.data.Store({
  storeId: 'soundCloudStore',

    proxy: {
      type: 'memory',
      data: [
          {
           title: 'Test', duration: '3434', genre: 'stuff', created_at: '2011/06/18', id: '1'   
         }
      ]
    },
    fields:['duration', 'genre', 'created_at', 'title', 'id']
});

trackStore.load(
  function() { 
    Ext.create('Ext.grid.Panel', {
      title: 'Tracks',
      store: trackStore,
      stripeRows: false,
      columns: [
        { 
            header: 'Title', 
            dataIndex: 'title'

        },
        { header: 'Duration',  dataIndex: 'duration' },
        { header: 'Genre', dataIndex: 'genre' },
        { header: 'Created At', dataIndex: 'created_at'}
      ],
      height: 200,
      width: 475,
      renderTo: Ext.getBody(),
      listeners: {
        afterrender: function( )
        {
            view = this.getView();

            view.tip = Ext.create('Ext.tip.ToolTip', {
                target: view.el,
                delegate: view.itemSelector,
                trackMouse: true,
                renderTo: Ext.getBody(),
                listeners: {
                    beforeshow: function updateTipBody(tip) {
                        tip.update(this.data.title);
                    }
                }
            });
        }
    }

  });
});
});
错误

Uncaught TypeError: Cannot read property 'title' of undefined
你可以这样做, 使用事件“viewready”而不是“afterrender”:

你可以这样做, 使用事件“viewready”而不是“afterrender”:

listeners: {
    viewready: function(grid) {

        var view = this.getView();

        // record the current cellIndex
        grid.mon(view, {
            uievent: function(type, view, cell, recordIndex, cellIndex, e) {
                grid.cellIndex = cellIndex;
                grid.recordIndex = recordIndex;
            }
        });

        grid.tip = Ext.create('Ext.tip.ToolTip', {
            target: view.el,
            delegate: '.x-grid-cell',
            trackMouse: true,
            renderTo: Ext.getBody(),
            listeners: {
                beforeshow: function updateTipBody(tip) {
                    console.log(grid.cellIndex);
                    if (!Ext.isEmpty(grid.cellIndex) && grid.cellIndex !== -1) {
                        header = grid.headerCt.getGridColumns()[grid.cellIndex];
                        tip.update(grid.getStore().getAt(grid.recordIndex).get(header.dataIndex));
                    }
                }
            }
        });
    }
}