closable : false,
collapsible : false,
height : 500,
+ modal : true,
resizable : false,
title : "Select columns to use",
- width : 700,
+ width : 900,
items : [
{
xtype: 'GridPanel',
tableName : 'Images',
title : "Images",
grid : {
- xtype: 'Grid',
+ xtype: 'EditorGrid',
xns: Roo.grid,
listeners : {
render : function()
}
},
autoExpandColumn : 'desc',
+ clicksToEdit : 1,
loadMask : true,
dataSource : {
xtype: 'Store',
}
options.params = options.params || {};
options.params.table = _this.data.table;
+ },
+ load : function (_self, records, options)
+ {
+ // after load, if we have configuration already, overlay that
+ if (typeof(_this.data.cols) == 'undefined') {
+ return;
+ }
+ _this.data.cols_ex = _this.data.cols_ex || [];
+ var cmap = {}
+ Roo.each(_this.data.cols, function (col) {
+ cmap[col.column] = col;
+
+ });
+ Roo.each(records, function (col) {
+ col.set('use_ex', _this.data.cols_ex.indexOf(col.data.column) > -1 ? 1 : 0);
+
+ if (typeof(cmap[col.data.column]) != 'undefined') {
+
+ col.set('title', typeof(cmap[col.data.column].title) == 'undefined' ? '' : cmap[col.data.column].title);
+ col.set('use', 1);
+ }
+ if (!col.data.title.length) {
+
+ if (col.data.columnshort.substring(0, col.data.table.length) == col.data.table) {
+ // it's prefixed with table name..
+ col.set('title', col.data.columnshort.substring(col.data.table.length+1));
+ } else {
+ col.set('title', col.data.columnshort);
+ }
+ }
+
+
+ // what about descption..
+ });
+
+
+
}
},
remoteSort : true,
fields : [
{ name: 'use', type: 'int'} ,
{ name: 'use_ex', type: 'int'},
- 'table', 'column', 'ctype', 'desc', 'columnshort'
+ 'table', 'column', 'ctype', 'desc', 'columnshort', 'title'
]
}
},
{
xtype: 'ColumnModel',
xns: Roo.grid,
- dataIndex : 'table',
- header : 'Table',
- width : 100,
- renderer : function(v) { return String.format('{0}', v); }
+ dataIndex : 'column',
+ header : 'Column',
+ width : 150,
+ renderer : function(v,x,r) {
+ if (r.data.table == _this.data.table) {
+
+ return String.format('<B>{0}</B>', v);
+ }
+ return String.format('{0}...{1}', r.data.table, r.data.columnshort);
+ }
},
{
xtype: 'ColumnModel',
xns: Roo.grid,
- dataIndex : 'column',
- header : 'Column',
+ dataIndex : 'title',
+ header : 'Title',
width : 150,
renderer : function(v,x,r) {
- if (r.data.table == _this.data.table) {
+
+ var u = r.data.use * 1;
+ u += (r.data.use_ex*1);
- return String.format('{0}', v);
+ return String.format('{0}', u ? v : '');
+ },
+ editor : {
+ xtype: 'GridEditor',
+ xns: Roo.grid,
+ field : {
+ xtype: 'TextField',
+ xns: Roo.form
}
- return String.format('.....{0}', r.data.columnshort);
}
},
{
width : 50,
renderer : function(v) {
- v = v*1;
-
-
-
- if ((v & 8) > 0 && (v & 4) > 0) return 'DATETIME';
- if ((v & 8) > 0) return 'TIME';
- if ((v & 4) > 0) return 'DATE';
- if ((v & 16) > 0) return 'BOOL';
- if ((v & 2) > 0) return 'STRING';
- if ((v & 1) > 0) return 'NUMBER';
- return v;
-
+ return v;
}
},
{
listeners : {
click : function (_self, e)
{
- var ret = Roo.apply({}, _this.data);
-
+ var ret = Roo.applyIf({ cols : [], cols_ex: [] }, _this.data);
+
_this.grid.ds.each(function(r) {
- if (r.data.use) {
- ret.cols.push(r.data);
+ if (r.data.use*1) {
+
+ var d = Roo.apply({}, r.json);
+ Roo.apply(d, r.data);
+ ret.cols.push(d);
+
}
- if (r.data.use_ex) {
+ if (r.data.use_ex*1) {
ret.cols_ex.push( r.data.column );
}
- })
+ });
- this.callback(ret);
+ if (!ret.cols_ex.length) {
+ Roo.MessageBox.alert("Error", "Select at least one Display/expand col");
+ return;
+ }
+ Roo.log(ret);
+
+ _this.dialog.hide();
+ _this.callback(ret);
}