2 Replies Latest reply on Feb 26, 2007 11:54 PM by Paul_Barbieux

    How to count lines of a DataGrid inside a Repeater ?

    Paul_Barbieux
      Hi;

      I have a DataGrid inside a Repeater:
      I try to adjust the height of my DataGrid depending on the number of lines provided by my DataProvider ( bijslagLines is a XMLList).
      How can I count the number of elements provided by my DataProvider in this case ? I wrote this code, but sometimes it send errors ("Error: Repeater is not executing. at mx.core::Repeater/get currentIndex() ...").

      <mx:Repeater id=" REPEATKIND" dataProvider="{ bijslagLines}">
      <mx:Panel>
      <mx:LinkButton label="{ REPEATKIND.currentItem.@naam}" />
      <mx:DataGrid id="KINDTABLE" dataProvider="{ REPEATKIND.currentItem.line}"
      rowCount="{KINDTABLE[ REPEATKIND.currentIndex].dataProvider.length}">
      <mx:columns>
      <mx:DataGridColumn dataField="maand052005" />
      <mx:DataGridColumn dataField="maand062005" />
      ...
      </mx:columns>
      </mx:DataGrid>
      </mx:Panel>
      </mx:Repeater>

      bijslagLines is a XMLList:

      <kind naam="...">
      <line>
      <type/>
      <maand052005>...</maand052005>
      <maand062005>...</maand062005>
      </line>
      ...
      </kind>
        • 1. Re: How to count lines of a DataGrid inside a Repeater ?
          peterent Level 2
          You can't do it this way - the Repeater's job is to create multiple instances of components that appear within its tags. You have to do math:

          <mx:DataGrid rowHeight="24" height="{bijslagLines.length*24}" dataProvider="{bijslagLines}" ... >
          ...
          </mx:DataGrid>
          • 2. How to count lines of a DataGrid inside a Repeater ?
            Paul_Barbieux Level 1
            Thank's but but the goal of this code is to create one DataGrid by <kind> tag, and each DataGrid containing one line for each <line> tag within <kind>.

            bijslagLines.length gives the number of <kind> and not the number of <line> within <kind> tags in my dataProvider (XMLList). With your solution all DataGrid have same size, not correctly adjusted...

            The code KINDTABLE[0].dataProvider.length gives the correct number of data lines in my first DataGrid. Now my problem is to replace the [0] by the current index at the creation time...