0

I am new to Flex and trying to modify some existing code. I am trying to It uses and AdvancedDataGrid. In the click event, the ListEvent is passed in, and the code is able to access properties such as event.itemRenderer.data.feature.

I would like to check whether the user has clicked on a parent (group) record or the child record; at runtime, I can see that the property I want to access is event.itemRenderer.listData.hasChildren. However, the listData property of itemRenderer does not show up in intellisense, and when I try to access that at design time, the project will not build because of the error "Access of possibly undefined property listData". But the property .data.feature doesn't show up in intellisense at design time either, and that builds and runs just fine.

What do I need to do to access event.itemRenderer.listData without throwing errors when I build the project? Do I need to capture a different event, or cast the event object or one of its properties into another object that will have the properties I need at runtime (I've investigated these options but cannot find info on how to do that).

Many thanks for any insight.

Meg
  • 157
  • 3
  • 8

1 Answers1

1

You probably have to perform a cast using IDropInListItemRenderer and AdvancedDataGridListData. Something like this:

((event.itemRenderer as IDropInListItemRenderer).listData as AdvancedDataGridListData).hasChildren
JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • Thanks but this just throws more 'Access of undefined property' errors. – Meg Jun 16 '11 at 17:51
  • Well, something is amiss. Break up the line into multiple statements; and figure out which piece is throwing the "Access of undefined property errors". It is possible that one of the casts is wrong or returning null. – JeffryHouser Jun 16 '11 at 18:08