Here’s the entire survey.grid.js. Basically it’s the redirects.grid.js with different names
Survey.grid.Survey = function(config) {
config = config || {};
var cb = new Ext.ux.grid.CheckColumn({
header: _('survey.active')
,dataIndex: 'active'
,width: 40
,sortable: true
,onMouseDown: function(e, t){
//checks/unchecks
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
}
//send ajax request to update the data
Ext.Ajax.request({
url : Survey.config.connectorUrl ,
params : { action : 'mgr/survey/updateFromGrid', data: {/* how do I get the row */} },
method: 'POST',
success: function ( result, request ) {
//Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText);
console.log(1);
},
failure: function ( result, request) {
//Ext.MessageBox.alert('Failed', result.responseText);
console.log(0);
}
});
}
});
Ext.applyIf(config,{
id: 'survey-grid-survey'
,url: Survey.config.connectorUrl
,baseParams: { action: 'mgr/survey/getList' }
,fields: ['id','name','description','active','menu']
,paging: true
,remoteSort: true
,anchor: '95%'
,autoExpandColumn: 'name'
,save_action: 'mgr/survey/updateFromGrid'
,autosave: true
,plugins: [cb]
,columns: [{
header: _('id')
,dataIndex: 'id'
,sortable: true
,width: 60
},{
header: _('survey.name')
,dataIndex: 'name'
,sortable: true
,width: 100
,editor: { xtype: 'textfield' }
},{
header: _('survey.description')
,dataIndex: 'description'
,sortable: false
,width: 350
,editor: { xtype: 'textfield' }
}, cb]
,tbar:[{
xtype: 'textfield'
,id: 'survey-search-filter'
,emptyText: _('survey.search...')
,listeners: {
'change': {fn:this.search,scope:this}
,'render': {fn: function(cmp) {
new Ext.KeyMap(cmp.getEl(), {
key: Ext.EventObject.ENTER
,fn: function() {
this.fireEvent('change',this);
this.blur();
return true;
}
,scope: cmp
});
},scope:this}
}
}
,{
text: _('survey.survey_create')
,handler: { xtype: 'survey-window-survey-create' ,blankValues: true }
}]
});
Survey.grid.Survey.superclass.constructor.call(this,config)
};
Ext.extend(Survey.grid.Survey,MODx.grid.Grid,{
search: function(tf,nv,ov) {
var s = this.getStore();
s.baseParams.query = tf.getValue();
this.getBottomToolbar().changePage(1);
this.refresh();
}
,getMenu: function() {
var m = [{
text: _('survey.survey_update')
,handler: this.updateSurvey
},'-',{
text: _('survey.survey_remove')
,handler: this.removeSurvey
}];
this.addContextMenuItem(m);
return true;
}
,updateSurvey: function(btn,e) {
if (!this.updateSurveyWindow) {
this.updateSurveyWindow = MODx.load({
xtype: 'survey-window-survey-update'
,record: this.menu.record
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
} else {
this.updateSurveyWindow.setValues(this.menu.record);
}
this.updateSurveyWindow.show(e.target);
}
,removeSurvey: function() {
MODx.msg.confirm({
title: _('survey.survey_remove')
,text: _('survey.survey_remove_confirm')
,url: this.config.url
,params: {
action: 'mgr/survey/remove'
,id: this.menu.record.id
}
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
}
});
Ext.reg('survey-grid-survey',Survey.grid.Survey);
Survey.window.UpdateSurvey = function(config) {
config = config || {};
Ext.applyIf(config,{
title: _('survey.survey_update')
,url: Survey.config.connectorUrl
,baseParams: {
action: 'mgr/survey/update'
}
,fields: [{
xtype: 'hidden'
,name: 'id'
},{
xtype: 'textfield'
,fieldLabel: _('survey.name')
,name: 'name'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('survey.description')
,name: 'description'
,width: 300
},{
xtype: 'checkbox'
,fieldLabel: _('survey.active')
,name: 'active'
,inputValue: 1
}]
});
Survey.window.UpdateSurvey.superclass.constructor.call(this,config);
};
Ext.extend(Survey.window.UpdateSurvey,MODx.Window);
Ext.reg('survey-window-survey-update',Survey.window.UpdateSurvey);
Survey.window.CreateSurvey = function(config) {
config = config || {};
Ext.applyIf(config,{
title: _('survey.survey_create')
,url: Survey.config.connectorUrl
,baseParams: {
action: 'mgr/survey/create'
}
,fields: [{
xtype: 'textfield'
,fieldLabel: _('survey.name')
,name: 'name'
,width: 300
},{
xtype: 'textarea'
,fieldLabel: _('survey.description')
,name: 'description'
,width: 300
},{
xtype: 'checkbox'
,fieldLabel: _('survey.active')
,name: 'active'
,inputValue: 1
,checked: false
}]
});
Survey.window.CreateSurvey.superclass.constructor.call(this,config);
};
Ext.extend(Survey.window.CreateSurvey,MODx.Window);
Ext.reg('survey-window-survey-create',Survey.window.CreateSurvey);