1 Reply Latest reply on May 1, 2008 8:21 PM by ntsiii

    Custom renderers

    ashishshrowty
      I have use case where i need to have the custom renderer format a LinkButton. I want to pass a function reference/pointer so that when the LinkButton is clicked, the method is invoked in the parent component. How do I accomplish this? I tried passing it in and referring it as {data.functionReference} within the renderer, but nothing happens. Is this even possible?

      Thanks for any help!
        • 1. Re: Custom renderers
          ntsiii Level 3
          This is not a good approach. Renderers need to be data driven. For example, is the link button method the same for all rows? I'm sure not. So how were you planning to pass a different function to each row?

          The best solution is to use events.
          Have a string in your data that indicates what action is to take place.

          In the renderer, read this string from data, and set it in a public property

          On click of the LinkButton, dispatch and event:
          dispatchEvent(new Event("myLinkButtonClick",true); //the 'true' makes the event bubble.

          in the parent app, set a listener for "myLinkButtonClick".

          In the handler, use event.target to get a reference to the renderer instance that dispatched the event.

          From that reference, get the action string, and then go from there.

          Tracy