3 Replies Latest reply on Jul 9, 2009 9:01 PM by sri harsha namala

    syntax question

    cpthk0 Level 1

      I am writing a dataGrid and using itemRenderer to override the default display mode into a LinkButton

      Here is my itemRenderer component file:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
           
           <mx:LinkButton id="downloadButton" label="Download" 
                click="navigateToURL(new URLRequest({data.href}), '_blank')"/> 
      
      </mx:Canvas>
      

      Flex builder keeps giving me a compile error at the "data.href". I don't know what kind of syntax error did I do.

       

      I got it compiled if I remove the curly brackets, but I really need to have data binding over here, since the value may gets changed later.

        • 1. Re: syntax question
          sri harsha namala Level 2

          Hi,

                        See But from where you will change the Values ,

                        If you change the Values dynamically to  the DataProvider the code which u gave will work

                        Once go through the below Code here if you change the X value of the DataGrid and

                          when u click Sample button the changed Value will    be   shown in Alert.

           

           

           

                         <!--- Main.mxml--->

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="init()">
              <mx:Script>
                  <![CDATA[
                      import mx.collections.ArrayCollection;
                      [Bindable]
                      public var arr:ArrayCollection=new ArrayCollection()
                      private function init():void
                      {
                          for(var i:int=0;i<10;i++)
                          {
                              arr.addItem({X:i,Y:"SampleUrl"+i})
                          }
                      }
                  ]]>
              </mx:Script>
              <mx:DataGrid id="dg" dataProvider="{arr}" editable="true">
                  <mx:columns>
                      <mx:DataGridColumn dataField="X" headerText="X"/>
                      <mx:DataGridColumn dataField="Y" headerText="URL" itemRenderer="DataGridButton"/>
                  </mx:columns>
              </mx:DataGrid>
          </mx:Application>

           

          <!-- DataGridButton.mxml-->

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
              <mx:Button id="btn" click="show()" label="Sample"/>
              <mx:Script>
                  <![CDATA[
                      import mx.controls.Alert;
                      private function show():void
                      {
                          Alert.show(this.data.X);
                      }
                  ]]>
              </mx:Script>
          </mx:Canvas>

          • 2. Re: syntax question
            cpthk0 Level 1

            so in your code, I can change the Alert into a navigateToURL?

            • 3. Re: syntax question
              sri harsha namala Level 2

              ya you can change once test with it i think it should work.