EntityPicker.js (1237B)
1 Ext.define("PartKeepr.Widgets.EntityPicker", { 2 extend: "PartKeepr.Widgets.EntityQueryPanel", 3 4 initComponent: function () 5 { 6 this.callParent(arguments); 7 8 var bottomToolbar = Ext.create("Ext.toolbar.Paging", { 9 store: this.down("#grid").store, 10 enableOverflow: true, 11 dock: 'bottom', 12 displayInfo: false 13 }); 14 15 bottomToolbar.insert(0, [{ 16 xtype: 'button', 17 iconCls: "fugue-icon tick", 18 text: i18n("Select entity"), 19 itemId: "selectEntity", 20 disabled: true, 21 handler: this.onEntitySelect, 22 scope: this 23 }, '-']); 24 25 this.down("#grid").addDocked(bottomToolbar); 26 this.down("#grid").on("selectionchange", this.onSelectionChange, this); 27 this.down("#grid").on("itemdblclick", this.onEntitySelect, this); 28 }, 29 onSelectionChange: function (grid, selected) { 30 if (selected.length != 1) { 31 this.down("#selectEntity").disable(); 32 } else { 33 this.down("#selectEntity").enable(); 34 } 35 }, 36 onEntitySelect: function () { 37 this.fireEvent("entityselect", this.down("#grid").getSelection()[0]); 38 }, 39 });