4 AssociateDialog =
function() {};
6 AssociateDialog.prototype = {
18 needPageRefresh:
false,
29 show:
function(type, sourceGrid, oid, associateAs, needPageRefresh) {
32 this.grid =
new wcmf.grid.Grid();
35 for (var i=0; i<sourceGrid.columnDefs.length; i++)
37 var origCol = sourceGrid.columnDefs[i];
38 columnDefs.push({
id:origCol.id, dataIndex:origCol.dataIndex, header:origCol.header, width:origCol.width,
39 sortable:origCol.sortable, renderer:this.grid.renderColumnDefault.createDelegate(this.grid)});
41 this.grid.init(
'', type,
'', columnDefs, {paging:
true, singleSelect:
false}, []);
42 var extGrid = this.grid.getGridImpl();
45 var selModel = extGrid.getSelectionModel();
46 selModel.on(
'selectionchange', this.selectionChanged.createDelegate(
this));
48 var dlg =
new Ext.Window({
49 applyTo:Ext.DomHelper.append(document.body, {tag:
'div'}),
58 handler: this.submitDlg.createDelegate(
this),
69 this.sourceGrid = sourceGrid;
71 this.associateAs = associateAs;
72 this.needPageRefresh = needPageRefresh;
74 extGrid.un(
"celldblclick", this.grid.cellDblClicked,
this.grid);
75 extGrid.on(
"celldblclick", this.submitDlg,
this);
78 this.grid.getGridImpl().getSelectionModel().clearSelections();
82 selectionChanged:
function(selModel) {
83 var buttons = this.dialog.buttons;
84 for (var i=0; i<buttons.length; i++) {
85 if (buttons[i].getText() ==
'Submit') {
86 if (selModel.getCount() > 0)
95 submitDlg:
function() {
96 document.body.style.cursor =
"wait";
97 var records = this.grid.getGridImpl().getSelectionModel().getSelections();
99 if (records.length > 0) {
100 for (var i=0; i<records.length-1; i++)
101 ids += records[i].
id+
",";
102 ids += records[records.length-1].id;
104 Action.perform(
'associate', {oid:this.oid, associateoids:ids, associateAs:this.associateAs}, this.actionPerformed,
this);
110 actionPerformed:
function(record, arg, success) {
111 document.body.style.cursor =
"";
112 if (this.needPageRefresh)
115 this.sourceGrid.load();