Results 1 to 2 of 2

Thread: Column Widget Grid Error

  1. #1
    Sencha User
    Join Date
    Dec 2015
    Posts
    118
    Answers
    12

    Default Answered: Column Widget Grid Error

    Hello,
    I am using widget column to show a grid.

    here

    I get an error when I initially click on the subgrid.
    Is there a workaround beside using rowwidget?

    Thank you,

  2. Try the following override of 'Ext.grid.CellContext' class:

    Code:
    Ext.define('override.grid.CellContext', {
        override: 'Ext.grid.CellContext',
        
            setRow: function(row) {
            var me = this,
                dataSource = me.view.dataSource,
                oldRecord = me.record,
                count;
            
            if (row !== undefined && row !== null) {
                // Row index passed, < 0 meaning count from the tail (-1 is the last, etc) 
                if (typeof row === 'number') {
                    count = dataSource.getCount();
                    row = row < 0 ? Math.max(count + row, 0) : Math.max(Math.min(row, count - 1), 0);
                    
                    me.rowIdx = row;
                    me.record = dataSource.getAt(row);
                }
                // row is a Record 
                else if (row.isModel) {
                    me.record = row;
                    me.rowIdx = dataSource.indexOf(row);
                }
                // row is a grid row, or Element wrapping row 
                else if (row.tagName || row.isElement) {
                    me.record = me.view.getRecord(row);
     
                    // If it's a placeholder record for a collapsed group, index it correctly 
                    me.rowIdx = me.record ? (me.record.isCollapsedPlaceholder ? dataSource.indexOfPlaceholder(me.record) : dataSource.indexOf(me.record)) : -1;
                }
            }
            if (me.record !== oldRecord) {
                me.generation++;
            }
            return me;
        },
        
        setColumn: function(col) {
            var me = this,
                colMgr = me.view.getVisibleColumnManager(),
                oldColumn = me.column;
     
            // Maintainer: 
            // We MUST NOT update the context view with the column's view because this context 
            // may be for an Ext.locking.View which spans two grid views, and a column references 
            // its local grid view. 
            if (col !== undefined && col !== null) {
                if (typeof col === 'number') {
                    me.colIdx = col;
                    me.column = colMgr.getHeaderAtIndex(col);
                } else if (col.isHeader) {
                    me.column = col;
                    // Must use the Manager's indexOf because view may be a locking view 
                    // And Column#getVisibleIndex returns the index of the column within its own header. 
                    me.colIdx = colMgr.indexOf(col);
                }
            }
            if (me.column !== oldColumn) {
                me.generation++;
            }
            return me;
        }
    });

  3. #2
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Try the following override of 'Ext.grid.CellContext' class:

    Code:
    Ext.define('override.grid.CellContext', {
        override: 'Ext.grid.CellContext',
        
            setRow: function(row) {
            var me = this,
                dataSource = me.view.dataSource,
                oldRecord = me.record,
                count;
            
            if (row !== undefined && row !== null) {
                // Row index passed, < 0 meaning count from the tail (-1 is the last, etc) 
                if (typeof row === 'number') {
                    count = dataSource.getCount();
                    row = row < 0 ? Math.max(count + row, 0) : Math.max(Math.min(row, count - 1), 0);
                    
                    me.rowIdx = row;
                    me.record = dataSource.getAt(row);
                }
                // row is a Record 
                else if (row.isModel) {
                    me.record = row;
                    me.rowIdx = dataSource.indexOf(row);
                }
                // row is a grid row, or Element wrapping row 
                else if (row.tagName || row.isElement) {
                    me.record = me.view.getRecord(row);
     
                    // If it's a placeholder record for a collapsed group, index it correctly 
                    me.rowIdx = me.record ? (me.record.isCollapsedPlaceholder ? dataSource.indexOfPlaceholder(me.record) : dataSource.indexOf(me.record)) : -1;
                }
            }
            if (me.record !== oldRecord) {
                me.generation++;
            }
            return me;
        },
        
        setColumn: function(col) {
            var me = this,
                colMgr = me.view.getVisibleColumnManager(),
                oldColumn = me.column;
     
            // Maintainer: 
            // We MUST NOT update the context view with the column's view because this context 
            // may be for an Ext.locking.View which spans two grid views, and a column references 
            // its local grid view. 
            if (col !== undefined && col !== null) {
                if (typeof col === 'number') {
                    me.colIdx = col;
                    me.column = colMgr.getHeaderAtIndex(col);
                } else if (col.isHeader) {
                    me.column = col;
                    // Must use the Manager's indexOf because view may be a locking view 
                    // And Column#getVisibleIndex returns the index of the column within its own header. 
                    me.colIdx = colMgr.indexOf(col);
                }
            }
            if (me.column !== oldColumn) {
                me.generation++;
            }
            return me;
        }
    });
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

Similar Threads

  1. [OPEN] Progress Widget in Grid Widget Column applies wrong CSS class
    By agarberi in forum Ext JS 6.x Bugs
    Replies: 3
    Last Post: 16 Dec 2016, 12:51 AM
  2. Replies: 1
    Last Post: 28 Apr 2016, 12:24 PM
  3. Tree panel as a widget column leads to error
    By yorl1n in forum Ext 5: Bugs
    Replies: 4
    Last Post: 7 Jun 2015, 10:50 PM
  4. [CLOSED] Error with Conditional Rendered Widget (in Widget Column)
    By chamacs in forum Ext 5: Bugs
    Replies: 6
    Last Post: 16 Apr 2015, 7:36 AM
  5. Replies: 2
    Last Post: 20 Sep 2014, 4:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •