We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44982
    • 3 Posts
    This is script from example. But I nead load list from file from array, not from modObjectGetListProcessor. How to do this?

    Calendar.grid.Calendar = function(config) {
    	config = config || {};
        
    	Ext.applyIf(config,{
            		id: 'calendar-grid-calendar'
            		,url: Calendar.config.connectorUrl
            		,baseParams: { action: 'mgr/calendar/getList' }
            		,fields: ['id','year','cort_status']
            		,paging: true
            		,remoteSort: true
            		,anchor: '97%'
            		,autoExpandColumn: 'name'
            		,columns: [{
            			header: "id"
            			,dataIndex: 'id'
            			,sortable: true
            			,width: 60
            		},{
            			header: "Date"
            			,dataIndex: 'year'
            			,sortable: true
            			,width: 100
            			,editor: { xtype: 'textfield' }
            		},{
            			header: "Status"
            			,dataIndex: 'cort_status'
            			,sortable: false
            			,width: 350
            			,editor: { xtype: 'textfield' }
            		}]
    			});
    		
      Calendar.grid.Calendar.superclass.constructor.call(this,config)
    };
    [ed. note: flytracer last edited this post 13 years, 1 month ago.]
      • 4172
      • 5,888 Posts
      what exactly are you after. There may allready be solutions out there, but we would need a bit more background-infos before making suggestions.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44982
        • 3 Posts
        This my files:

        calendar.js
        var Calendar = function(config) {
            config = config || {};
            Calendar.superclass.constructor.call(this,config);
        };
        Ext.extend(Calendar,Ext.Component,{
            page:{},window:{},grid:{},tree:{},panel:{},combo:{},config: {}
        });
        Ext.reg('calendar',Calendar);
        Calendar = new Calendar(); 


        home.panel.js
        Calendar.panel.Home = function(config) {
        	config = config || {};
        	Ext.apply(config,{
        		border: false
        		,baseCls: 'modx-formpanel'
        		,cls: 'container'
        		,items: [{
        			html: '<h2>Calendar manager</h2>'
        			,border: false
        			,cls: 'modx-page-header'
        		},{
        			xtype: 'modx-tabs'
        			,defaults: { border: false ,autoHeight: true }
        			,border: true
        			,items: [{
        				title: 'Calendar'
        				,defaults: { autoHeight: true }
        				,items: [{
        					html: '<p>Calendar manager</p>'
        					,border: false
        					,bodyCssClass: 'panel-desc'
        				},{
        					xtype: 'calendar-grid-calendar'
        					,cls: 'main-wrapper'
        					,preventRender: true
        				}]
        			}]
        		}]
        	});
        	Calendar.panel.Home.superclass.constructor.call(this,config);
        };
        Ext.extend(Calendar.panel.Home,MODx.Panel);
        Ext.reg('calendar-panel-home',Calendar.panel.Home);



        calendar.grid.ja
        Calendar.grid.Calendar = function(config) {
            config = config || {};
             
            Ext.applyIf(config,{
                        id: 'calendar-grid-calendar'
                        ,url: Calendar.config.connectorUrl
                        ,baseParams: { action: 'mgr/calendar/getList' }
                        ,fields: ['id','year','cort_status']
                        ,paging: true
                        ,remoteSort: true
                        ,anchor: '97%'
                        ,autoExpandColumn: 'name'
                        ,columns: [{
                            header: "id"
                            ,dataIndex: 'id'
                            ,sortable: true
                            ,width: 60
                        },{
                            header: "Date"
                            ,dataIndex: 'year'
                            ,sortable: true
                            ,width: 100
                            ,editor: { xtype: 'textfield' }
                        },{
                            header: "Status"
                            ,dataIndex: 'cort_status'
                            ,sortable: false
                            ,width: 350
                            ,editor: { xtype: 'textfield' }
                        }]
                    });
                 
          Calendar.grid.Calendar.superclass.constructor.call(this,config)
        };
        
        Ext.extend(Calendar.grid.Calendar,MODx.grid.Grid);
        Ext.reg('calendar-grid-calendar',Calendar.grid.Calendar);



        I nead load array from php file to grid.
          • 4172
          • 5,888 Posts
          An easy way to create a CMP with an extjs-grid is to use MIGXdb.
          Here's an example:

          http://rtfm.modx.com/extras/revo/migxdb/migxdb.tutorials/migxdb.create-doodles-manager-with-help-of-migxdb

          you don't need all the db-stuff there.
          Set the packageName to your package
          and the processorspath to 'calendar'

          and create a file under 'components/yourpackage/processors/mgr/calendar/getlist.php'

          with code like that:

          $rows = $yourArray;
          
          return $this->outputArray($rows, count($rows));


          This should fill the grid with your data.


          Something like that should also be possible with you existing code and a custom-getlist-processor, but here I'm not sure.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 3749
            • 24,544 Posts
            If the array is in PHP, your JS code won't know about it unless you either use a getList processor, or write it as a JSON string into the page content.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 10487 MODX Staff
              • 1,535 Posts
              You can still use modObjectGetListProcessor to load information from other sources, you just need to override the process() method to fetch your data from whatever source you require.

              Here's an example of how I used modObjectGetListProcessor for ClientConfig to pull in data from Google Fonts via curl for a combo box.

                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com
                • 44982
                • 3 Posts
                Thanks all, especially - Gary Nutting!
                Im use modObjectGetListProcessor method process(), all works good.

                class CalendarGetListProcessor extends modObjectGetListProcessor {
                    public $languageTopics = array('calendar:default');
                    
                    public function process() {
                        $list = array(
                            'id' => 1,
                            'year' => '2013',
                            'cort_status' => '2',
                        );
                        
                        
                        $total = count($list);
                
                        return $this->outputArray($list,$total);
                    }
                }
                return 'CalendarGetListProcessor';