3 Replies Latest reply on Mar 13, 2011 10:51 AM by leroivt

    advanceddatagrid itemrenderer

    leroivt

      Hi!

      I'm new to flex and I have a question.

      I use an intemrenderer for a advanceddatagrid control in flex4. How can I remove or delete a label from datagrid itemrenderer if the text is null?

       

      My app:

       

      <mx:AdvancedDataGrid id="dg_ViewDetaliiPZ" designViewDataType="flat" dataProvider="{afisezDetalii}"
                                       left="3" right="3" top="10" bottom="60" variableRowHeight="true">
           <mx:columns>
                 <mx:AdvancedDataGridColumn headerText="Ora:" dataField="time_start" width="45"/>                  
                 <mx:AdvancedDataGridColumn headerText="Ora:" dataField="time_stop" width="45"/>
                 <mx:AdvancedDataGridColumn id ="act" headerText="Activitatea:" wordWrap="true" itemRenderer="myActivitatiRenderer"/>
            </mx:columns>
      </mx:AdvancedDataGrid>

       

       

      and the itemrenderer:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:MXAdvancedDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                                        xmlns:s="library://ns.adobe.com/flex/spark"
                                        xmlns:mx="library://ns.adobe.com/flex/mx"
                                        focusEnabled="true">
          <fx:Style>
              .myColorStyle {
                  fontWeight: bold;
               /* fontSize: 15; */
                  color: #FF0000;
              }
             
          </fx:Style>

       

      <s:HGroup height="100%">


          <s:VGroup left="7" top="7" width="100%" variableRowHeight="true" height="100%">
              <s:Label id="lblObiect" top="7" width="100%" left="5" styleName="myColorStyle" text="{data.obiect + data.tema}"/>

              // here if the data.id_exercitii is null I want to delete this label (to decrease my row height) and if is not null, to show it :

              <s:Label id="lblExercitii" left="5" width="100%" text="{data.id_exercitii}"/>            

                                                                                                                                                                                                                                                                       

                // same thing here for biblio:

              <s:Label id="lblBibliografie" left="5" text="{data.biblio}"/>                                      

              <s:Label id="lblConduce" left="5" text="Conduce: {data.conducator}"/>
         
          </s:VGroup>
         
          <s:VGroup left="7" width="100" height="100%">
              <s:Label id="lblLoc" top="0" left="0" right="0" text="{data.loc}"
                       width="100%" height="100%" textAlign="center"
                       verticalAlign="middle"/>
          </s:VGroup>
         
         
      </s:HGroup>


      </s:MXAdvancedDataGridItemRenderer>

       

       

      Thank you all who read this post!