7 Replies Latest reply on Jun 17, 2009 2:33 AM by *Prashant Shelke*

    Created a Application from Database ok! But how can I play with it?

    EMelville Level 1

      Hi!

       

      I went through the steps and created a Application from a Database. All is ok, but how do I get just one of the values in the mysql database to display in a {label}? I've been playing with this for a couple of months and i'm pretty sure it's something i've simply missed. (Bleh)

       

      Thanks!

       

      Here's a picture of what i'm trying to do.

       

      http://www.thealphacompany.net/wth.jpg

       

      I do appreciate any assistance available!

       

      MXML Code (Works a-ok):

       

      <mx:DataGrid id="dataGrid"
                     dataProvider="{dataArr}"
                     rowCount="8"
                     editable="true"
                     resizableColumns="true" 
                     headerRelease="setOrder(event);"
                     right="10" left="10" top="10" bottom="204">
                          <mx:columns>
                               <mx:DataGridColumn headerText="id" dataField="idCol" />
                               <mx:DataGridColumn headerText="event_desc" dataField="event_descCol" />
                               <mx:DataGridColumn headerText="logo_url" dataField="logo_urlCol" />
                               <mx:DataGridColumn headerText="background_img" dataField="background_imgCol" />
                               <mx:DataGridColumn headerText="txt_color" dataField="txt_colorCol" />
                               <mx:DataGridColumn headerText="txt_font" dataField="txt_fontCol" />
                               <mx:DataGridColumn headerText="txt_size" dataField="txt_sizeCol" />
                               <mx:DataGridColumn headerText="reg_email_from" dataField="reg_email_fromCol" />
                               <mx:DataGridColumn headerText="reg_email_address" dataField="reg_email_addressCol" />
                               <mx:DataGridColumn headerText="reg_email_message" dataField="reg_email_messageCol" />
                               <mx:DataGridColumn headerText="current_slidedeck" dataField="current_slidedeckCol" />
                               <mx:DataGridColumn headerText="total_slides" dataField="total_slidesCol" />
      
      
      
      
      
      
      <mx:DataGridColumn headerText="url_materials" dataField="url_materialsCol" />
                          
      
      
      
      
      <mx:DataGridColumn headerText="url_materials_title" dataField="url_materials_titleCol" />
                          </mx:columns>
                </mx:DataGrid>
      

       

      What the heck i'm trying to do:

       

      <mx:Label x="40" y="229" text="{????}" />
      

        • 1. Re: Created a Application from Database ok! But how can I play with it?
          *Prashant Shelke* Level 4

          <mx:Label text="{dataGrid.selectedItem.url_materials}" ../>


          this will bind selected item's any one of dataFields as you required.

          1 person found this helpful
          • 2. Re: Created a Application from Database ok! But how can I play with it?
            EMelville Level 1

            Actually I was planning to get rid of the dataGrid eventually. I'd rather just display it in labels.

             

            I embed the code:

             

            1. No errors

            2. The label becomes blank

             

            It did give me the idea of trying this:

             

            <mx:Label x="40" y="229" text="{dataGrid.selectedItem.url_materialsCol}" />

             

            And it worked obviously when I selected the specific item. But how do I get "That" specifc item into that text label field without the grid.

             

            Idea:

             

            I suppose I could make the table invisible and have the Selected item predefined on init();

             

            Let me know if you have a better (and simpler) solution.

             

            Thanks!

            • 3. Re: Created a Application from Database ok! But how can I play with it?
              *Prashant Shelke* Level 4

              Actually according u r description in last post, i think your dont want dataGrid over there & if you want to set url_materisalsCols value,


              try this:


              var arrColl:ArrayCollection; // suppose this is dataProvider for dataGrid & you can retrieve any attribute from any object of this as


              arrColl.getItemAt(0).url_materisalsCols // 1st row

              arrColl.getItemAt(1).url_materisalsCols // 2st row


              Here 0, 1 are same as selectedIndex of dataGrid just ensure arrColl != null && arrColl.length > 0


              This better than creating & hiding dataGrid

              1 person found this helpful
              • 4. Re: Created a Application from Database ok! But how can I play with it?
                EMelville Level 1

                The current dataprovider is: dataProvider="{dataArr}"

                 

                I've tried:

                 

                  <mx:Script>

                    <![CDATA[

                    import mx.collections.ArrayCollection;

                 

                private function actSetIndex(): void {

                    dataArr.getItemAt(0).url_materialsCol // 1st row

                      }

                   

                    ]]>

                    </mx:Script>

                 

                And created a button to execute it but no luck. Zero errors, just blank.

                 

                Lets back up.

                 

                I've tried:

                 

                <mx:DataGrid id="dataGrid"

                dataProvider="{dataArr}"

                rowCount="8"

                editable="true"

                resizableColumns="true"

                headerRelease="setOrder(event);"

                selectedIndex="0"

                right="10" left="10" top="10" bottom="204">

                <mx:columns>

                <mx:DataGridColumn headerText="id" dataField="idCol" />

                <mx:DataGridColumn headerText="event_desc" dataField="event_descCol" />

                <mx:DataGridColumn headerText="logo_url" dataField="logo_urlCol" />

                <mx:DataGridColumn headerText="background_img" dataField="background_imgCol" />

                <mx:DataGridColumn headerText="txt_color" dataField="txt_colorCol" />

                <mx:DataGridColumn headerText="txt_font" dataField="txt_fontCol" />

                <mx:DataGridColumn headerText="txt_size" dataField="txt_sizeCol" />

                <mx:DataGridColumn headerText="reg_email_from" dataField="reg_email_fromCol" />

                <mx:DataGridColumn headerText="reg_email_address" dataField="reg_email_addressCol" />

                <mx:DataGridColumn headerText="reg_email_message" dataField="reg_email_messageCol" />

                <mx:DataGridColumn headerText="current_slidedeck" dataField="current_slidedeckCol" />

                <mx:DataGridColumn headerText="total_slides" dataField="total_slidesCol" />

                <mx:DataGridColumn headerText="url_materials" id="bleh" dataField="url_materialsCol" />

                <mx:DataGridColumn headerText="url_materials_title" dataField="url_materials_titleCol" />

                </mx:columns>

                </mx:DataGrid>

                 

                But the selected index isn't selected. Any ideas on how to make the selected index pre defined?

                • 5. Re: Created a Application from Database ok! But how can I play with it?
                  *Prashant Shelke* Level 4

                  selectedIndex=0 by default will work only in case u have data already came, else u r data is getting set so selectedIndex becomes -1.


                  Do one thing, set as below


                  dataGrid.dataProvider = dataArr; // dataArr might not present at the intialization of data Grid.

                  dataGrid.selectedIndex = 0 ;

                  • 6. Re: Created a Application from Database ok! But how can I play with it?
                    EMelville Level 1

                    Works like a charm. A quick workaround that I can deal with later on in the future.

                     

                    Thanks!!