2 Replies Latest reply on Nov 19, 2007 5:32 PM by dnii

    How to: Need header to span 2 columns in AdvancedDataGrid

      I have an AdvancedDataGrid with many columns, some of them grouped together so that I have multiple levels of column headers.

      As it turns out, I need to combine two column headers into one that spans two columns and each of these columns has currently an itemRenderer assigned (one is a subclass of Label and one is a subclass of Image).

      The problem is that if you just group the columns and give the ColumnGroup a headerText and leave the headerText for the individual columns blank, you will get an extra level of empty headers => not pretty at all.

      I would like that empty header level to disappear...

      My first thought was to create a new custom renderer that would be comprised of my custom Label and custom Image classes but I don't seem to be able to figure out how to access the datafields to populate my cells...

      Then my second thought was to see if I could combine the two headers for the two columns into one and not deal with datafields. Seems the simpler approach to me but I am stuck there too...

      Could anybody help me along?

      Thanks a bunch!
        • 1. Re: How to: Need header to span 2 columns in AdvancedDataGrid
          I think combining to headers is not possible with the current design, so the second approach may not work.
          I can suggest 2 approaches but both of them have some drawbacks.

          One approach is to use a custom item renderer extending HBox and use it as itemRenderer for a column for which the header should be spanning other columns. It will give the header spanning kind of looks but the drawback here is that you can't get the resize fuctionality within that column.

          Second approach is to use the rendererProviders and make the first row as your headers and remove the default headers i.e

          showHeaders= false;
          lockedRowCount = 1;

          and write a custom renderer which implements IDataRenderer and use r.data which is an AdvancedDataGridColumn to get the headerText of that column and use it in your renderer.

          Now, set rendererProviders for the first row.
          The drawback here is that, you can not sort the data.
          • 2. How to: Need header to span 2 columns in AdvancedDataGrid
            dnii Level 1
            Thanks for spending time on my problem.

            I definitely need sorting capabilities and in my case the resizing of columns is disabled.
            Your response confirmed that the first approach of creating a custom item renderer is really the way to go.

            I will start digging some more to get this working then.