class GeneralIndexGetSubListProcessor extends modObjectGetListProcessor {
public $languageTopics = array('qpharmacist:default');
public function process() {
//$sql = "SELECT * FROM jobs";
$id = $this->getProperty('id',false);
$list = array();
$i = 1;
$resource = $this->modx->getObject('modResource', $id);
if ($resource->hasChildren()) {
$children = $resource->getMany('Children');
foreach ($children as $child) {
$listItem = array(
'id' => $id,
'title' => $child->get('pagetitle'),
);
$list[] = $listItem;
}
}
$total = count($list);
return $this->outputArray($list,$total);
}
}
return 'GeneralIndexGetSubListProcessor';Ext.applyIf(config,{
id: 'generalindex-grid-generalindexitems'
,url: GeneralIndex.config.connectorUrl
,baseParams: {
action: 'mgr/generalindex/getsublist',
}
,blankValues: true
,fields: ['id', 'title', 'link']
,paging: true
,remoteSort: true
,anchor: '97%'
,autoExpandColumn: 'name'
,columns: [{
header: 'id'
,dataIndex: 'id'
,width: 30
},{
header: "Book title"
,dataIndex: 'title'
,sortable: true
,width: 200
,editor: { xtype: 'textfield' }
},{
header: "link title"
,dataIndex: 'link'
,sortable: true
,width: 200
,editor: { xtype: 'textfield' }
}]SELECT * FROM some_table WHERE parent_id='$id'
'rowclick' : function(grid, rowIndex, e){
var store = grid.getStore();
var value = store.getAt(rowIndex).get('id');
if (!this.ItemGeneralIndexWindow) {
this.ItemGeneralIndexWindow= MODx.load({
xtype: 'generalindex-window-generalindex-item'
,record: this.menu.record
,gridParams: value
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
}
this.ItemGeneralIndexWindow.setValues(this.menu.record);
this.ItemGeneralIndexWindow.show(e.target);
}
GeneralIndex.window.ItemGeneralIndex = function(config) {
config = config || {};
Ext.applyIf(config,{
title: 'Links'
,fields: [{
xtype: 'hidden'
,name: 'id'
},{
xtype: 'generalindex-grid-generalindexitems'
,cls: 'main-wrapper'
,preventRender: true
}]
});
console.log(this.fp.getForm().getValues());
GeneralIndex.window.ItemGeneralIndex.superclass.constructor.call(this,config);
};
Ext.extend(GeneralIndex.window.ItemGeneralIndex, MODx.Window);
Ext.reg('generalindex-window-generalindex-item',GeneralIndex.window.ItemGeneralIndex);
GeneralIndex.grid.GeneralIndexItem = function(config) {
config = config || {};
Ext.applyIf(config,{
id: 'generalindex-grid-generalindexitems'
,url: GeneralIndex.config.connectorUrl
,baseParams: {
action: 'mgr/generalindex/getsublist',
query: '10',
}
,blankValues: true
,fields: ['id', 'title', 'link']
,paging: true
,remoteSort: true
,anchor: '97%'
,autoExpandColumn: 'name'
,columns: [{
header: 'id'
,dataIndex: 'id'
,width: 30
},{
header: "Book title"
,dataIndex: 'title'
,sortable: true
,width: 200
,editor: { xtype: 'textfield' }
},{
header: "link title"
,dataIndex: 'link'
,sortable: true
,width: 200
,editor: { xtype: 'textfield' }
}]
,tbar:[{
text: 'Create event'
,handler: { xtype: 'generalindex-window-generalindex-create' ,blankValues: true }
}]
});
GeneralIndex.grid.GeneralIndexItem.superclass.constructor.call(this,config)
};
Ext.extend(GeneralIndex.grid.GeneralIndexItem,MODx.grid.Grid);
Ext.reg('generalindex-grid-generalindexitems',GeneralIndex.grid.GeneralIndexItem);
I can't say out of my head, where exactly to pass the id to this subgrid's baseParams here.
But I could say how you would do this same thing with MIGXdb, if this would be an option for you.
'rowclick' : function(grid, rowIndex, e){
var store = grid.getStore();
var value = store.getAt(rowIndex).get('id');
if (!this.ItemGeneralIndexWindow) {
this.ItemGeneralIndexWindow= MODx.load({
xtype: 'generalindex-window-generalindex-item'
,record: this.menu.record
,gridParams: value
,listeners: {
'success': {fn:this.refresh,scope:this}
}
});
}
this.ItemGeneralIndexWindow.setValues(this.menu.record);
this.ItemGeneralIndexWindow.show(e.target);
}
,baseParams: {
action: 'mgr/generalindex/getsublist',
query: '10',
}