2 Replies Latest reply on Feb 15, 2010 9:33 AM by Chaitanya Yeluri

    how to insert button(or other control) in row of  Datagrid

    Magesh R Level 1

      Hi Friends,

       

      i create button with in datagrid but the button it can't display of datagrid ..If i any mistake the below coding please any one help to me..

      coding Is:

       

      <mx:DataGrid id="grd1"  x="41" y="203" width="159">
      <mx:columns>
         <mx:DataGridColumn headerText="Button" >
          <mx:itemRenderer>
           <fx:Component>
            <mx:HBox>
               <s:Button name="OK"  id="btn_ok"/>
            </mx:HBox>
           </fx:Component>
          </mx:itemRenderer>
      </mx:DataGridColumn>

      <mx:DataGridColumn headerText="Cancel button" >
          <mx:itemRenderer>
           <fx:Component>
            <mx:HBox>
               <s:Button name="Cancel"  id="btn_cancel"/>
            </mx:HBox>
           </fx:Component>
          </mx:itemRenderer>
      </mx:DataGridColumn>

      <mx:columns>

      </mx:DataGrid>

       

       

      Thanks,

      Magesh R.

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

        • 1. Re: how to insert button(or other control) in row of  Datagrid
          Gregory Lafrance Level 6

          Two problems I see with your code. First, to get any rows in your dataGrid, you need a dataProvider defined. The itemRenderer in general just renderers the data from the dataprovider. It is possible to have additional controls in other columns that are not populated by the dataProvider, but you need to at least define a dataProvider.

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          1 person found this helpful
          • 2. Re: how to insert button(or other control) in row of  Datagrid
            Chaitanya Yeluri

            There are few mistakes in your code. The one with red color are mistakes.

             

            <mx:DataGrid id="grd1"  x="41" y="203" width="159">
            <mx:columns>
               <mx:DataGridColumn headerText="Button" >
                <mx:itemRenderer>
                 <fx:Component>
                  <mx:HBox>
                     <s:Button name="OK"  id="btn_ok"/>
                  </mx:HBox>
                 </fx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>

            <mx:DataGridColumn headerText="Cancel button" >
                <mx:itemRenderer>
                 <fx:Component>
                  <mx:HBox>
                     <s:Button name="Cancel"  id="btn_cancel"/>
                  </mx:HBox>
                 </fx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>

            <mx:columns>

            </mx:DataGrid>

             

            1. instead of fx type mx. even for s:button use mx:button
            2. you should have a closing tag fro columns </mx:columns>
            3. you sould not use name property for button unless it is your custome property. use label instead of name.

             

              I am sending you sample MXML code as attachment after correcting your code. Just go through it. try to execute.