torsten@348: /*
torsten@348: * Grid to list Proben
torsten@348: */
torsten@4: Ext.define('Lada.view.proben.List' ,{
torsten@4: extend: 'Ext.grid.Panel',
torsten@4: alias: 'widget.probenlist',
torsten@374: store: 'ProbenList',
torsten@37: viewConfig: {
torsten@37: maxHeight: 350,
torsten@37: emptyText: 'Keine Proben gefunden.',
torsten@37: // minHeight and deferEmptyText are needed to be able to show the
torsten@37: // emptyText message.
torsten@37: minHeight: 35,
torsten@37: deferEmptyText: false
torsten@37: },
torsten@4: initComponent: function() {
torsten@63: this.dockedItems = [
torsten@63: {
torsten@63: xtype: 'toolbar',
torsten@63: dock: 'top',
torsten@63: items: [
torsten@63: {
torsten@63: text: 'Hinzufügen',
rrenkert@391: icon: 'gfx/list-add.png',
torsten@63: action: 'add'
torsten@357: },
torsten@357: {
torsten@357: text: 'Import',
rrenkert@391: icon: 'gfx/svn-commit.png',
torsten@357: action: 'import'
torsten@380: },
torsten@380: {
torsten@380: text: 'Export',
rrenkert@391: icon: 'gfx/svn-update.png',
torsten@380: action: 'export'
torsten@63: }
torsten@63: ]
torsten@63: }
torsten@63: ];
torsten@238: this.columns = [];
torsten@4: this.callParent(arguments);
torsten@239: },
torsten@348: /**
torsten@348: * Setup columns of the Grid dynamically based on a list of given cols.
torsten@353: * The function is called from the {@link Lada.controller.Sql#selectSql
torsten@348: * select sql event}
torsten@348: * @parameter {Array} List of cols to show in the Grid.
torsten@348: */
torsten@249: setupColumns: function(cols) {
torsten@364: var rcols = [];
torsten@374: var mfields = [];
torsten@374:
torsten@258: rcols.push({header: 'RW', dataIndex: 'readonly', width: 30, renderer: render_readonly});
torsten@374: mfields.push(new Ext.data.Field({name: 'readonly'}));
torsten@249: for (var i = cols.length - 1; i >= 0; i--){
torsten@249: rcols.push(cols[i]);
torsten@374: mfields.push(new Ext.data.Field({name: cols[i].dataIndex}));
torsten@364: }
torsten@374: this.store.model.setFields(mfields);
torsten@249: this.reconfigure(this.store, rcols);
torsten@4: }
torsten@4: });
torsten@258:
torsten@348: /**
torsten@348: * Helper function to render a readonly symbol per row in the grid
torsten@348: * @param {Boolean} flag if the symbol is a readonly symbol.
torsten@348: */
torsten@258: function render_readonly (value) {
torsten@258: if (value) {
torsten@363: return '
';
torsten@258: } else {
torsten@363: return '
';
torsten@258: }
torsten@258: }