We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46830
    • 4 Posts
    I've created a processor for loading grid, but I need to pass values ​​inthis processor which will be loaded this grid. That I need to initialize pereadty ID. How to do it?

    processor:

    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';


    grid:

    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' }
        		}]
      • 46830
      • 4 Posts
      I need to pass the id in order to form a specific query to the database!

      SELECT * FROM some_table WHERE parent_id='$id'
      


      Help please, if I can not find.

      Maybe you can add to the grid action request string?
        • 4172
        • 5,888 Posts
        not sure, what you are trying.
        Where should this id come from?

        What are you trying to build at all?
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 46830
          • 4 Posts
          Main grid have click listener. In this listener I'm create window with grid. And I dont know how send data from grid to window and to grid.

          This code create window.
          '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);
                          
                      }
          


          This is initialize window code:

          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);
          


          This is grid code:

          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 need pass value data form listener to grid query param, how do this?
            • 4172
            • 5,888 Posts
            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.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 46830
              • 4 Posts
              Quote from: Bruno17 at Mar 10, 2014, 11:58 AM
              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.

              Sorry, I just badly explained.

              I have main grid in panel. It has listener if click to item.

              '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);
                               
                          }

              Here I take the value of the id. And I have to pass it in the grid which is in the popup window.
              But I do not know how to pass this value thither.
              I tried to do it through the following functions:
              gridParams: value and this.ItemGeneralIndexWindow.setValues(this.menu.record)

              But how to get it ID here, I do not know:
                      ,baseParams: { 
                            action: 'mgr/generalindex/getsublist', 
                            query: '10',
                      }

              I need this value in query paramiter. '10' I put this to the test.