2 Replies Latest reply on Aug 31, 2009 8:55 PM by Madhav Subedi

    datagrid with LinkButton/Hyperlink for DataGridColumn(simple one)...

    karnatis Level 1

      Hi All,

       

         I'm having below code

       

         <mx:Script>

       

           [Bindable]
                   public var mySourceDataProvider:Array = new Array({isRowSelected: false, name:'Name1', age:10, comment:'Comment1'},
                               {isRowSelected: false, name:'Name2', age:20, comment:'Comment2'},
                               {isRowSelected: false, name:'Name3', age:30, comment:'Comment3'},
                               {isRowSelected: false, name:'Name4', age:40, comment:'Comment4'});

       

         </mx:Script>

       

         <mx:DataGrid id="mySourceDataGrid" dataProvider="{mySourceDataProvider}" headerRelease="headRelEvt(event);" x="54" y="65" width="365">
                   <mx:columns>
                           <mx:DataGridColumn sortable="false">
                                   <mx:headerRenderer >
                                       <mx:Component>
                                           <mx:HBox horizontalAlign="center" verticalAlign="middle">
                                               <mx:CheckBox selected="{outerDocument.check_flg}" click="outerDocument.headerCheckBoxSelection(event);"/>
                                           </mx:HBox>
                                       </mx:Component>
                                    </mx:headerRenderer>
                                   <mx:itemRenderer>
                                           <mx:Component>                                             
                                                   <mx:VBox horizontalAlign="center" verticalAlign="middle">
                                                           <mx:CheckBox id="source"
                                                               selected="{data.isRowSelected}"
                                                               click="outerDocument.updateSelectedRowFlag(event);"/>
                                                   </mx:VBox>
                                           </mx:Component>
                                   </mx:itemRenderer>
                           </mx:DataGridColumn>
                           <mx:DataGridColumn dataField="name"/>

                           <mx:DataGridColumn dataField="age"/>                    

                           <mx:DataGridColumn dataField="comment"/>

                   </mx:columns>    

      </mx:DataGrid>

       

         The grid is showing correctly with data and it is working fine. Now I need to have hyperlink/linkbutton on name column displayed in DataGrid. When I press this link/button it should navigate to different page(.mxml)...

       

          Can someone please let me know how to do this?

       

          Thanks in advance.

       

      Regards,

      sharath.

        • 1. Re: datagrid with LinkButton/Hyperlink for DataGridColumn(simple one)...
          karnatis Level 1

          I'm able to solve this problem but having question on setting style on linkbutton. Linkbutton style is not working

           

          <mx:DataGridColumn editable="false" textAlign="center" id="dgCol_buttons" >                       
                                  <mx:itemRenderer>
                                      <mx:Component>
                                      <mx:LinkButton styleName="htmlLink" label="{data.name}" toolTip="Accept WorkOrder"/>                                                   
                                      </mx:Component>
                                  </mx:itemRenderer>
          </mx:DataGridColumn>

           

          <mx:Style>
                 
                 .htmlLink        {
                      fontSize: 12;
                      fontWeight: normal;
                      text-decoration:underline;           
                  }

                
          </mx:Style>

           

          text-decoration is defined as underline but it is not showing underline for linkbutton column.

           

          Can you please advice, how to solve this problem.

          • 2. Re: datagrid with LinkButton/Hyperlink for DataGridColumn(simple one)...
            Madhav Subedi Level 4

            declare the style within the itemrenderer, and wrap the style/linkbutton by a canvas ( container ):

             

             

            <mx:DataGridColumn editable="false"
                textAlign="center"
                id="dgCol_buttons">
                 <mx:itemRenderer>
                      <mx:Component>
                           <mx:Canvas>
                                <mx:Style>        
                                   .htmlLink        
                                   {
                                          fontSize: 12;
                                          fontWeight: normal;
                                          text-decoration:underline;            
                                     }                       
                                </mx:Style>
                                <mx:LinkButton styleName="htmlLink"
                                    label="{data.name}"
                                    toolTip="Accept WorkOrder"/>
                           </mx:Canvas>
                      </mx:Component>
                 </mx:itemRenderer>
            </mx:DataGridColumn>