4 Replies Latest reply on Jan 29, 2011 8:54 AM by kiran7881

    Is it possible to skip executing  custom itemRenderer Configured for a Datagrid column ??

    kiran7881 Level 1

      Hi ,

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle" xmlns:comps="comps.*">
          <mx:Array id="sampleData">
              <mx:String>Row 1</mx:String>
              <mx:String>Row 2</mx:String>
              <mx:String>Row 3</mx:String>
              <mx:String>Row 4</mx:String>
              <mx:String>Row 5</mx:String>
              <mx:String>Row 6</mx:String>
              <mx:String>Row 7</mx:String>
             
          </mx:Array>
        
          <mx:VBox>
           
              <mx:DataGrid width="500" height="227" dataProvider="{sampleData}">
                  <mx:columns>
                      <mx:DataGridColumn headerText="Actual Row"/>
                      <mx:DataGridColumn headerText="ItemRenderer" >
                         
                            <mx:itemRenderer>
                              <mx:Component>
                                 
                                  <comps:RightTestRenderer>
                                     
                                  </comps:RightTestRenderer>
                              </mx:Component>
                            </mx:itemRenderer>

                      </mx:DataGridColumn>
                  </mx:columns>
              </mx:DataGrid>
          </mx:VBox>

      </mx:Application>

       

      =============

      RightTestRenderer.mxml

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalAlign="left" verticalAlign="middle">
          
         
          <mx:VBox id="jai" height="100%" width="100%">
              <mx:Image source="images/canvas.png" visible="true" height="100%" width="100%"/>
          </mx:VBox>
             
         
      </mx:HBox>

      ========

       

      Based on some conditon , i want to skip executing  itemRenderer RightTestRenderer.mxml at Runtime ??

       

      Is this possible ??

       

      Please help .

        • 1. Re: Is it possible to skip executing  custom itemRenderer Configured for a Datagrid column ??
          Abhinav Sharma Level 2

          I didn't get your question properly. As much I understand you would have to handle it in ItemRender.

           

          One possible way (not the best):

          1. Create application Level public variable. say - boolShouldRender. This will be checked inside Item Renderer.
          2. Acces it in Item renderer and customize it according to requirement.
              <mx:VBox id="myvbox" visible="{parentApplication.boolShouldRender}">
                  <mx:Image source="images/canvas.png" />
              </mx:VBox>
          

           

          Thanks.

           

          -

          Abhinav

          • 2. Re: Is it possible to skip executing  custom itemRenderer Configured for a Datagrid column ??
            kiran7881 Level 1

            Anyways , thanks for the reply .

             

             

             

            <mx:DataGrid width="500" height="227" dataProvider="{sampleData}">
                        <mx:columns>
                            <mx:DataGridColumn headerText="Actual Row"/>
                            <mx:DataGridColumn id="hh" headerText="ItemRenderer"  >
                               
                                  <mx:itemRenderer >
                                    <mx:Component>
                                        <comps:RightTestRenderer  enabled="false"  includeInLayout = "false" visible = "false" show="false">
                                        </comps:RightTestRenderer>
                                    </mx:Component>
                                  </mx:itemRenderer>
                            </mx:DataGridColumn>
                        </mx:columns>
                    </mx:DataGrid>

             

             

             

            My question was actually depending on the condition , i dont to skip executing the itemRenderer on a condition . I dont want to execute this below .

            <mx:itemRenderer >
                                     <mx:Component>
                                         <comps:RightTestRenderer   enabled="false"  includeInLayout = "false" visible = "false"  show="false">
                                         </comps:RightTestRenderer>
                                     </mx:Component>
                                   </mx:itemRenderer>

            • 3. Re: Is it possible to skip executing  custom itemRenderer Configured for a Datagrid column ??
              saisri2k2 Level 4

              Are yu trying to hide something on a condition? like the Image in tis case?

               

              if so override the data property in the itemrenderer and validate te conditon in the data to show/not show the image.

              • 4. Re: Is it possible to skip executing  custom itemRenderer Configured for a Datagrid column ??
                kiran7881 Level 1

                Thanks , I have seen that . But my requirement is different .

                I have solved that , by chnaging ItemRenderer at runtime using ClassFactory .