2 Replies Latest reply on Jun 29, 2006 8:47 PM by Keiko

    Urgent CFGrid-Combo-DataProvider Question

    Keiko Level 1

      Dear all,

      I have this code to create combos in cfgrid. My question now is .. how to replace the hardcoded countries with query? The code is saved in AS file (.as). The full codes can be found at http://cfpim.blogspot.com/2005_08_01_cfpim_archive.html See Grid cellRenderer in Flash forms topic.

      function createChildren(Void) : Void{
      combo = createClassObject( ComboBox, "combo", 1, {owner:this});
      combo.dataProvider = [{data:'SGP',label:'Singapore'}, {data:'JPN',label:'Japan'}, {data:'USA',label:'United States of America'}, {data:'AUS',label:'Australia'}, {data:'IND',label:'India'}];
      combo.addEventListener("change", this);
      }

      Thanks in advance
      Keiko

        • 1. Re: Urgent CFGrid-Combo-DataProvider Question
          Dan Bracuk Level 5
          Since nobody, especially me, appears to know, I am going to suggest something that may or may not work.

          Something like:
          <cfsavecontent variable="something">
          function createChildren(Void) : Void{
          combo = createClassObject( ComboBox, "combo", 1, {owner:this});
          <cfoutput query="yourquery">
          combo.dataProvider = [{data:'#code#',label:'#name#'}
          <cfif currentrow lt recordcount>, </cfif>
          </cfoutput>
          ];
          combo.addEventListener("change", this);
          }

          </cfsaveconent>
          • 2. Re: Urgent CFGrid-Combo-DataProvider Question
            Keiko Level 1

            Dan,

            I wanted to try your method, but I got another error (if I take the content of .AS file and put it inside cfsavecontent). Below is my code ...

            Seems that I cannot place import or createChild inside CFSaveContent. Any help will be very much appreciated.

            Keiko
            ------------------------------------------------------------------------------------------ ----------------------

            <cfform format="Flash" skin="haloSilver">

            <cfsaveContent variable="onLoad">

            import mx.controls.ComboBox;

            class GridRenderer extends mx.core.UIComponent {

            var combo;
            var listOwner : MovieClip;
            var getCellIndex : Function;
            var getDataLabel : Function;

            function createChildren(Void) : Void{
            combo = createClassObject( ComboBox, "combo", 1, {owner:this});
            combo.dataProvider = [{data:'SGP',label:'Singapore'}, {data:'JPN',label:'Japan'}, {data:'USA',label:'United States of America'}, {data:'AUS',label:'Australia'}, {data:'IND',label:'India'}];
            combo.addEventListener("change", this);
            }

            function getPreferredHeight(Void) : Number{
            return combo != undefined ? 25:0;
            }

            function setValue(str:String, item:Object){
            var val = item.country;
            for(var i = 0; i < combo.dataProvider.length; i++){
            combo.dataProvider .data == val ? combo.selectedIndex = i : '';
            }
            }

            function change() {
            listOwner.editField(getCellIndex().itemIndex, getDataLabel(), combo.selectedItem.data);
            }

            }

            function(){
            _level0.myGrid.rowHeight=25;
            _level0.myGrid.getColumnAt(2).cellRenderer = GridRenderer;
            }.call()

            </cfsavecontent>

            <!--- grid with 3 columns name, firstName, department --->
            <cfgrid name="myGrid" width="400">
            <cfgridColumn name="Name">
            <cfgridColumn name="Country">
            <cfgridrow data="Name 1, SGP">
            <cfgridrow data="Name 2, USA">
            </cfgrid>

            <cfinput type="submit" name="cmdSubmit" value="Submit to see the form dump">
            <!--- onLoad trigger --->
            <cfinput type="text" visible="No" width="0" height="0" name="trigger2" bind="{1==2?'':#onLoad#}">

            </cfform>