JuHwon
JuHwon

Reputation: 2063

ExtJS Grid Filter doesnt appear

i got an ExtJS Grid in my view and now i do want to add some column filters... i've already searched in the web, though i didnt succeed. The problem is if i open the submenu of the column where i can sort etc. i do not see the option Filter.

the following code is a section of my view script:

Ext.define('Project.my.name.space.EventList', {
    extend: 'Ext.form.Panel',
    require: 'Ext.ux.grid.FiltersFeature',

    bodyPadding: 10,
    title: Lang.Main.EventsAndRegistration,
    layout: {
        align: 'stretch',
        type: 'vbox'
    },

    initComponent: function () {
        var me = this;

        Ext.applyIf(me, {
            items: [

                ...

                {
                xtype: 'gridpanel',
                title: '',
                store: { proxy: { type: 'direct' } },
                flex: 1,
                features: [filtersCfg],
                columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'Title',
                    text: Lang.Main.CourseTitle,
                    flex: 1,
                    filterable: true
                },
                {
                    xtype: 'datecolumn',
                    dataIndex: 'StartDate',
                    text: Lang.Main.StartDate,
                    format: Lang.Main.DateFormatJS,
                    flex: 1,
                    filter: { type: 'date' }
                },
                {
                    xtype: 'datecolumn',
                    dataIndex: 'EndDate',
                    text: Lang.Main.EndDate,
                    format: Lang.Main.DateFormatJS,
                    flex: 1, // TODO: filter
                },
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'Participants',
                    text: Lang.Main.Participants,
                    flex: 1
                },
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'LocationName',
                    text: Lang.Main.Location,
                    flex: 1
                },
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'Status',
                    text: Lang.Main.Status,
                    flex: 1, // TODO: filter
                }],
                dockedItems: [{
                    xtype: 'toolbar',
                    items: [{
                        icon: 'Design/icons/user_add.png',
                        text: Lang.Main.RegisterForEvent,
                        disabled: true
                    },
                    {
                        icon: 'Design/icons/user_delete.png',
                        text: Lang.Main.Unregister,
                        disabled: true
                    },
                    {
                        icon: 'Design/icons/application_view_list.png',
                        text: Lang.Main.Show,
                        disabled: true
                    },
                    {
                        icon: 'Design/icons/calendar_edit.png',
                        text: Lang.Main.EditButtonText,
                        hidden: true,
                        disabled: true
                    },
                    {
                        icon: 'Design/icons/calendar_add.png',
                        text: Lang.Main.PlanCourse,
                        hidden: true
                    }]
                }]
                }
            ]
        });

        me.callParent(arguments);

        ...

        this.grid = this.query('gridpanel')[0];

        this.grid.on('selectionchange', function (view, records) {
            var selection = me.grid.getSelectionModel().getSelection();
            var event = (selection.length == 1) ? selection[0] : null;
            var registered = event != null && event.data.Registered;
            me.registerButton.setDisabled(registered);
            me.unregisterButton.setDisabled(!registered);
            me.showButton.setDisabled(!records.length);
            me.editButton.setDisabled(!records.length);            

        });
    }
});

here is also a pastebin link of the code : http://pastebin.com/USivWX9S

UPDATE

just noticed while debugging that i get an JS error in the FiltersFeature.js file in this line:

createFilters: function() {
        var me = this,
            hadFilters = me.filters.getCount(),
            grid = me.getGridPanel(),
            filters = me.createFiltersCollection(),
            model = grid.store.model,
            fields = model.prototype.fields,
Uncaught TypeError: Cannot read property 'prototype' of undefined
            field,
            filter,
            state;

please help me!

Upvotes: 2

Views: 3162

Answers (1)

A1rPun
A1rPun

Reputation: 16857

There are a couple of syntactic errors.

  • FiltersFeature is a grid feature and not a component.
  • You cannot extend an object literal (correct me if I'm wrong)

Use the filter like this:

var filtersCfg = {
    ftype: 'filters',
    local: true,
    filters: [{
        type: 'numeric',
        dataIndex: 'id'
    }]
};

var grid = Ext.create('Ext.grid.Panel', {
     features: [filtersCfg]
});

Upvotes: 1

Related Questions