Flex - Sending a parameter to a custom ItemRenderer?

后端 未结 10 1359
悲哀的现实
悲哀的现实 2020-12-24 07:37

What I am trying to accomplish to to get financial data in my Flex Datagrid to be color-coded--green if it\'s positive; red if it\'s negative. This would be fairly straight

10条回答
  •  佛祖请我去吃肉
    2020-12-24 07:55

    There's another technique, which, while it initially feels a little hacky is perhaps less cumbersome and cleaner in actual use.

    It involves the little-observed fact that an event dispatch is, of course, synchronous and the event object can be treated as a value object populated by any event handler.

    i.e. the ItemRenderer can do something like:

      ...
      var questionEvt:DynamicEvent = new DynamicEvent('answerMeThis', true, true);
      if (dispatchEvent(questionEvt))
      {
          if (questionEvent.answer == "some value")
          ....
    

    With a corresponding handler somewhere up the view hierarchy above the renderer that has a listener on the event and does something like:

    function handleAnswerMeThis(event:DynamicEvent):void
    {
         event.answer = "another value";
         event.dataHelper = new DataHelperThingy();
    }
    

    etc.

    It need not be a DynamicEvent - I'm just using that for lazy illustrative purposes.

提交回复
热议问题