Advertisement
Guest User

EXT JS Grid Filter View

a guest
Mar 8th, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ext.define('Project.my.name.space.EventList', {
  2.     extend: 'Ext.form.Panel',
  3.     require: 'Ext.ux.grid.FiltersFeature',
  4.  
  5.     bodyPadding: 10,
  6.     title: Lang.Main.EventsAndRegistration,
  7.     layout: {
  8.         align: 'stretch',
  9.         type: 'vbox'
  10.     },
  11.  
  12.     initComponent: function () {
  13.         var me = this;
  14.  
  15.         Ext.applyIf(me, {
  16.             items: [
  17.                
  18.                 ...
  19.                
  20.                 {
  21.                     xtype: 'gridpanel',
  22.                     extend: 'Ext.ux.grid.FiltersFeature',
  23.                     title: '',
  24.                     store: { proxy: { type: 'direct'} },
  25.                     flex: 1,
  26.                     features: [{
  27.                         ftype: 'filters',
  28.                         autoReload: false,
  29.                         local: true
  30.                     }],                
  31.                     columns: [
  32.                     {
  33.                         xtype: 'gridcolumn',
  34.                         dataIndex: 'Title',
  35.                         text: Lang.Main.CourseTitle,
  36.                         flex: 1,
  37.                         filterable: true
  38.                     },
  39.                     {
  40.                         xtype: 'datecolumn',
  41.                         dataIndex: 'StartDate',
  42.                         text: Lang.Main.StartDate,
  43.                         format: Lang.Main.DateFormatJS,
  44.                         flex: 1,
  45.                         filter: { type: 'date' }
  46.                     },
  47.                     {
  48.                         xtype: 'datecolumn',
  49.                         dataIndex: 'EndDate',
  50.                         text: Lang.Main.EndDate,
  51.                         format: Lang.Main.DateFormatJS,
  52.                         flex: 1,
  53.                         filterable: true //TODO: filter
  54.                     },
  55.                     {
  56.                         xtype: 'gridcolumn',
  57.                         dataIndex: 'Participants',
  58.                         text: Lang.Main.Participants,
  59.                         flex: 1
  60.                     },
  61.                     {
  62.                         xtype: 'gridcolumn',
  63.                         dataIndex: 'LocationName',
  64.                         text: Lang.Main.Location,
  65.                         flex: 1
  66.                     },
  67.                     {
  68.                         xtype: 'gridcolumn',
  69.                         dataIndex: 'Status',
  70.                         text: Lang.Main.Status,
  71.                         flex: 1,
  72.                         filter: {
  73.                             type: 'list',
  74.                             options: ['small', 'medium', 'large', 'extra large']
  75.                         }
  76.                     }],
  77.                     dockedItems: [{
  78.                         xtype: 'toolbar',
  79.                         items: [{
  80.                             icon: 'Design/icons/user_add.png',
  81.                             text: Lang.Main.RegisterForEvent,
  82.                             disabled: true
  83.                         },
  84.                         {
  85.                             icon: 'Design/icons/user_delete.png',
  86.                             text: Lang.Main.Unregister,
  87.                             disabled: true
  88.                         },
  89.                         {
  90.                             icon: 'Design/icons/application_view_list.png',
  91.                             text: Lang.Main.Show,
  92.                             disabled: true
  93.                         },
  94.                         {
  95.                             icon: 'Design/icons/calendar_edit.png',
  96.                             text: Lang.Main.EditButtonText,
  97.                             hidden: true,
  98.                             disabled: true
  99.                         },
  100.                         {
  101.                             icon: 'Design/icons/calendar_add.png',
  102.                             text: Lang.Main.PlanCourse,
  103.                             hidden: true
  104.                         }]
  105.                     }]
  106.                 }
  107.             ]
  108.         });
  109.  
  110.         me.callParent(arguments);
  111.        
  112.         ...
  113.  
  114.         this.grid = this.query('gridpanel')[0];
  115.  
  116.         this.grid.on('selectionchange', function (view, records) {
  117.             var selection = me.grid.getSelectionModel().getSelection();
  118.             var event = (selection.length == 1) ? selection[0] : null;
  119.             var registered = event != null && event.data.Registered;
  120.             me.registerButton.setDisabled(registered);
  121.             me.unregisterButton.setDisabled(!registered);
  122.             me.showButton.setDisabled(!records.length);
  123.             me.editButton.setDisabled(!records.length);            
  124.  
  125.         });
  126.     }
  127. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement