4 Replies Latest reply on Apr 15, 2007 11:30 PM by appu19

    Link button in data grid


      Can anyone tell me why the click action is not working when the link button is placed in datagrid.

      <mx:DataGridColumn dataField="edit" headerText="">
      <mx:LinkButton label="edit" click = "click1();">

      even if button is placed in the datagrid it is not working.
        • 1. Re: Link button in data grid
          peterent Level 2
          When you use the <mx:Component> tag you create a new scope. Its as if all of the content of the <mx:Component> were in another file. If you used a separate file for your renderer you wouldn't expect click() function to be recognized, right?

          You can modify your renderer like this to make it work:

          <mx:LinkButton label="edit" click = "outerDocument.click1();">

          Another option is to take advantage of the bubbling feature of the click event. Instead of putting the click handler on the LinkButton, put it on the DataGrid itself. Any click on the DataGrid will then trigger the event handler.

          The drawback to that is that EVERY click will call the event handler - either the LinkButton's click on a click on the header. Your event handler just has to examine the event data to determine what control originated the event.

          In this case, using outerDocument.click() is far easier, but you might need the bubbling property of the event at some point in the future.

          • 2. Re: Link button in data grid
            appu19 Level 1
            hi peter
            <mx:LinkButton label="edit" click = "outerDocument.click1();"> is not working again.
            i am getting an error stating "attempted access of inaccessible method through a reference with static type"

            can u plss help me out soon.

            • 3. Re: Link button in data grid
              ntsiii Level 3
              Make sure click1() is declared public.
              • 4. Re: Link button in data grid
                appu19 Level 1
                Thank you tracy n peter got the correct answer..

                Forgot to see that the function is public or not..

                outerDocument.click() worked out..

                Thanks once again.