Results 1 to 2 of 2

Thread: editorgrid.save() to coldFusion cfc.

  1. #1

    Default editorgrid.save() to coldFusion cfc.

    Hi All,

    I think I'm pretty close here, but I don't think I'm referring to my cfc correctly. I have 2 methods in my cfc, one that returns data to my grid, and one that will save the returned json from ext. My probelm is that when I call the save method for my datastore, the default cfc method (the getResourceGridJSON method i used to populate the grid)is used. Do I somehow need to change the baseparameters to submit to the correct cfc method?

    my cfc:

    Code:
    <cfcomponent>
    
        <cffunction name="getResourceGridJSON" OUTPUT="NO" access="remote" returntype="any">
            <cfargument NAME="PlanID" TYPE="NUMERIC" REQUIRED="YES">
    
            <cfquery name="getGrid" datasource="#application.Datasource#">
                SELECT LayoutUID, ResourceName, CostElementName, Month_1,
                          Month_2, Month_3, Month_4, Month_5, Month_6, Month_7,
                          Month_8, Month_9, Month_10, Month_11,Month_12
                FROM vResourceGrid
                WHERE vResourceGrid.PlanID = #PlanID#
            </cfquery>
        
            <cfreturn QueryConvertForGrid(getGrid,1,getGrid.recordcount)>
        </cffunction>
        
    
        <cffunction name="saveResourceGridJSON" OUTPUT="NO" access="remote" returntype="any">
            <cfargument NAME="JSONData" REQUIRED="YES">
    
            <!--- do parsing stuff... --->
            
            <!--- update database... --->
        
            <cfreturn "success">
        </cffunction>    
        
    </cfcomponent>
    my grid code:

    Code:
    // JavaScript Document
    Ext.namespace('ResourceGrids');
    
    // {{{ 
    ResourceGrids.resourceGrid = Ext.extend(Ext.grid.EditorGridPanel, { 
        
        initComponent:function(){    
        //call function below to set up datastore
            this.initGrid();
            //hardcoded configuration - cannot be changed from the outside
            var config = {
                store: this.myStore,
                colModel: this.resourceColModel,
                //autoHeight: true,        
                height: 300,
                clicksToEdit: 1,        
                collapsible : true,
                title: 'Resouces',
                autoScroll: true,
                //removed grouping
                plugins: this.summary
            };//eo config items
           
        //apply config
        Ext.apply(this, Ext.apply(this.initialConfig, config));    
        //call parent object
        ResourceGrids.resourceGrid.superclass.initComponent.apply(this, arguments)
        
        },//eo init component
        
        //called in init component - sets up datastore
        initGrid: function(){        
        
            //create record model for resource data
             this.recordModel = [
                {name: 'LAYOUTUID', type: 'int'},
                {name: 'RESOURCENAME', type: 'string'},
                {name: 'COSTELEMENTNAME', type: 'string'},
                 {name: 'MONTH_1', type: 'float', defaultValue: 0},
                {name: 'MONTH_2', type: 'float', defaultValue: 0},
                {name: 'MONTH_3', type: 'float', defaultValue: 0},
                {name: 'MONTH_4', type: 'float', defaultValue: 0},
                {name: 'MONTH_5', type: 'float', defaultValue: 0},
                {name: 'MONTH_6', type: 'float', defaultValue: 0},
                {name: 'MONTH_7', type: 'float', defaultValue: 0},
                {name: 'MONTH_8', type: 'float', defaultValue: 0},
                {name: 'MONTH_9', type: 'float', defaultValue: 0},
                {name: 'MONTH_10', type: 'float', defaultValue: 0},
                {name: 'MONTH_11', type: 'float', defaultValue: 0},
                {name: 'MONTH_12', type: 'float', defaultValue: 0},
                {name: 'total', type: 'float', defaultValue: 0}
             ];
             
            this.myReader = new Ext.data.CFQueryReader({id:'LAYOUTUID'},this.recordModel);
            
            //create store for resource data    
            this.myStore = new Ext.data.GroupingStore({
                url:'CFC/ResourceGrid.cfc',
                baseParams: {
                    method: 'getResourceGridJSON',
                    PlanID: 0,
                    returnFormat: 'json'
                },
                root: 'resources',
                reader: this.myReader,            
                //idProperty: 'LAYOUTUID',
                groupField: 'COSTELEMENTNAME',
                sortInfo: {field: 'COSTELEMENTNAME', direction: 'ASC'},
                writer: new Ext.data.JsonWriter(),
                autoSave:false,
                batch:true
            });
            
            //initialize pluging for grid summary
            this.summary = new Ext.ux.grid.GridSummary();
            
                //set up month column editor
            this.editorMonth = new Ext.form.NumberField({
               allowBlank: false,
               allowNegative: false,
               style: 'text-align:left'
            });
            
            
            //create colModel for reasource grid
            this.resourceColModel = new Ext.grid.ColumnModel([
                {header: "Layout ID", dataIndex: 'LAYOUTUID', hidden: true},
                {header: "Resouce Name", dataIndex: 'RESOURCENAME', ID:"resourceCol",
                    width: 100,
                    //removed grouping
                    summaryType: 'count',
                    summaryRenderer: function(v, params, data){
                        return ('Project ManPwr Dollars:');}
                },
                {header: "Cost Element", width: 150, dataIndex: 'COSTELEMENTNAME'},
                {header: "Nov", width: 50, summaryType: 'sum', dataIndex: 'MONTH_1', editor: this.editorMonth},
                {header: "Dec", width: 50, summaryType: 'sum', dataIndex: 'MONTH_2', editor: this.editorMonth},
                {header: "Jan", width: 50, summaryType: 'sum', dataIndex: 'MONTH_3', editor: this.editorMonth},
                {header: "Feb", width: 50, summaryType: 'sum', dataIndex: 'MONTH_4', editor: this.editorMonth},
                {header: "Mar", width: 50, summaryType: 'sum', dataIndex: 'MONTH_5', editor: this.editorMonth},
                {header: "Apr", width: 50, summaryType: 'sum', dataIndex: 'MONTH_6', editor: this.editorMonth},
                {header: "May", width: 50, summaryType: 'sum', dataIndex: 'MONTH_7', editor: this.editorMonth},
                {header: "Jun", width: 50, summaryType: 'sum', dataIndex: 'MONTH_8', editor: this.editorMonth},
                {header: "Jul", width: 50, summaryType: 'sum', dataIndex: 'MONTH_9', editor: this.editorMonth},
                {header: "Aug", width: 50, summaryType: 'sum', dataIndex: 'MONTH_10', editor: this.editorMonth},
                {header: "Sep", width: 50, summaryType: 'sum', dataIndex: 'MONTH_11', editor: this.editorMonth},
                {header: "Oct", width: 50, summaryType: 'sum', dataIndex: 'MONTH_12', editor: this.editorMonth},
                {header: "Total",
                    align: 'center',
                    summaryType: 'sum',
                    renderer: function(v, params, record){
                        return (record.data.MONTH_1*10000 + record.data.MONTH_2*10000 + record.data.MONTH_3*10000 + record.data.MONTH_4*10000 + record.data.MONTH_5*10000 + record.data.MONTH_6*10000 + record.data.MONTH_7*10000 + record.data.MONTH_8*10000 + record.data.MONTH_9*10000 + record.data.MONTH_10*10000 + record.data.MONTH_11*10000 + record.data.MONTH_12*10000)/10000;}
                }
            ]);    
            
        },//eo initgrid
        
        loadData:function(planID){
            this.myStore.load({params:{PlanID: planID}});
            //console.log('dataloaded from resource grid. planid:'+planID);
        },
        
        saveData:function(){
            console.log('about to call save()');
            this.myStore.save();
            console.log(this.myStore);
        }    
        
        
    }); // e/o extend 
      
    // register xtype 
    Ext.reg('resourceGrid', ResourceGrids.resourceGrid);
    here is the firebug data, the records are correct, but the method is not:


  2. #2

    Default

    I think I just solved it myself:

    this.myStore.setBaseParam('method', 'saveResourceGridJSON');

    works just fine...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •