Results 1 to 2 of 2

Thread: Extending Grid Feature?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2014
    Posts
    2

    Default Answered: Extending Grid Feature?

    Hi,

    I am trying to extend Grid summary feature but it's throwing an error

    PHP Code:
    Uncaught TypeErrorCannot read property 'childNodes' of null 
    Here's the code sample, modified from http://docs.sencha.com/extjs/4.2.1/#...eature.Summary

    PHP Code:

    Ext
    .define('TestResult', {    extend'Ext.data.Model',    fields: ['student', {        name'mark',        type'int'    }]});Ext.define('Ext.grid.feature.Summary2', {    extend'Ext.grid.feature.Summary',    alias'feature.summary2'});Ext.create('Ext.grid.Panel', {    width400,    height200,    title'Summary Test',    style'padding: 20px',    renderTodocument.body,    features: [{        ftype'summary2'    }],    store: {        model'TestResult',        data: [{            student'Student 1',            mark84        }, {            student'Student 2',            mark72        }, {            student'Student 3',            mark96        }, {            student'Student 4',            mark68        }]    },    columns: [{        dataIndex'student',        text'Name',        summaryType'count',        summaryRenderer: function(valuesummaryDatadataIndex) {            return Ext.String.format('{0} student{1}'valuevalue !== 's' '');        }    }, {        dataIndex'mark',        text'Mark',        summaryType'average'    }]}); 

  2. The summary feature has the view look it up in one of its functions using view.findFeature('summary');

    Code:
    renderTFoot: function(values, out) {
            var view = values.view,
                me = view.findFeature('summary');
    
            if (me.showSummaryRow) {
                out.push('<tfoot>');
                me.outputSummaryRecord(me.createSummaryRecord(view), values, out);
                out.push('</tfoot>');
            }
        },
    Including that function in the summary2 feature updating the lookup to 'summary2' made it work, although less than optimal.

    Code:
    Ext.define('Ext.grid.feature.Summary2', {
        extend: 'Ext.grid.feature.Summary',
        alias: 'feature.summary2',
        
         renderTFoot: function(values, out) {
            var view = values.view,
                me = view.findFeature('summary2');
    
            if (me.showSummaryRow) {
                out.push('<tfoot>');
                me.outputSummaryRecord(me.createSummaryRecord(view), values, out);
                out.push('</tfoot>');
            }
        }
        
    });
    I looked at the 5.01 code and the same lookup is in there, just in a different function (renderSummaryRow).

Posting Permissions

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