0

I am trying to overlay a label onto an AdvancedDataGrid when there are no results returned from a call for the data.

Here is a mockup of what I am trying to accomplish https://i.stack.imgur.com/6Djga.png

I tried following this previous answer: Drawing an overlay in custom flex component, but this would not work for me because an AdvancedDataGrid is not a Container (and as such does not have a rawChildren property).

I would prefer not to need to mess with the data provider, because this table will be used in many location which will have different columns and labelFields.

Any suggestions welcome.

Community
  • 1
  • 1
david
  • 3
  • 1

2 Answers2

2

To give a quick example as to what Flextras mentioned:

<s:Group>
  <mx:DataGrid dataProvider="{myDataProvider}">
    <mx:columns>
      <mx:DataGridColumn dataField="test1" />
      <mx:DataGridColumn dataField="test2" />
      <mx:DataGridColumn dataField="test3" />
      <mx:DataGridColumn dataField="test4" />
    </mx:columns>
  </mx:DataGrid>

  <s:Label text="Overlay text here" visible="{myDataProvider.length == 0}" x="10" y="35" />
</s:Group>
Jason Towne
  • 8,014
  • 5
  • 54
  • 69
  • Thanks for the reply, as I said in reply to Flextras comment this will not work for me because I can't place a container around every AdvancedDataGrid nor can I change our subclass of AdvancedDataGrid to be like this without breaking many things. – david Apr 20 '11 at 20:56
  • @david, Can you add an `ItemRenderer` to the `DataGrid`? – Jason Towne Apr 20 '11 at 21:30
0

Put the AdvancedDataGrid in a container along with the label overlay. Position the label on top of the DataGrid; and change it's visibility based on the dataProvider's length.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • Thanks for the reply, unfortunately this will not work for me because I am working with a large established code base where I can't change our subclass of AdvancedDataGrid to do that without breaking many things. – david Apr 20 '11 at 20:26
  • @David you just have to replace your subclass of the AdvancedDataGrid w/ another class that contains the container. That shouldn't be too hard. It may be tedious if you need to mirror many properties of the advancedDataGrid in the new class; but it should still be doable. – JeffryHouser Apr 20 '11 at 21:40
  • @David and @Flextras, yup this does work in practice, we did this with our extension of the ADG and used bindings to pass through the properties to the underlying ADG. It ended up being a mess to maintain (had multiple versions doing this so was easy to miss adding a binding for a new property in one version or the other). Ultimately we've had to go the route of re-factoring now and it will be a humongous pain to do so but basically we've opted to remove the passthrough and have the users of the grid deal with the component parts separately – shaunhusain Apr 20 '11 at 21:44
  • Essentially what was defined as single MXML node is now defined as a top level MXML node with properties that are the header/title region and the advanced data grid below it (the whole thing is actually an extension of Canvas, due to the size and nature of our projects we haven't been able to switch up to Flex 4) – shaunhusain Apr 20 '11 at 22:07
  • So I looked through our code some more and found a location with a canvas I can use to position the overlay. Thanks for all the help! – david Apr 21 '11 at 04:24