4 Replies Latest reply on Aug 22, 2006 6:03 AM by peterent

    Bolding single line in datagrid

      It seems like I'm getting buried in the abstracted language of Flex, but I'm trying to find a way to just make a single line in a datagrid bold. I know the index of the row, so that's easy.

      Is there a quick and dirty way to do this?

      I appreciate any help in advance.

        • 1. Re: Bolding single line in datagrid
          peterent Level 2
          The "quick and dirty" way. Hmm. I'm afraid not. You need an itemRenderer. And since you want every column to have the bold text, you'll need to use the same renderer for every column. I'd recommend writing a custom renderer (.MXML file).

          First, how do you know which row you want to make bold? Is it just because you want the 4th row or does it have something to do with the data? Usually there's something about the data that you use to determine the visual appearance.

          Let's say that in the data, when quantity is > 1000, you want boldfacing.

          Here's a drop-in itemRenderer for one of the columns. You can either repeat this in the same file or create a custom renderer.

          <mx:DataGridColumn headerText="..." dataField="...">
          <mx:Label fontWeight="{data.quantity > 1000 ? 'bold' : 'normal'}" />

          • 2. Re: Bolding single line in datagrid
            jsevlie Level 1
            I have a listing of at MOST 6 rows in a datagrid list, in order of a predetermined ranking. Amongst these 6 records, I want to highlight the current user's name, city/state, ranking, etc. I already know where they rank in the list, so I know the exact index as well.

            I will try your example and see what I come up with. I appreciate the help.

            Flex seems to be all about feeling your way around, bumping into new things, figuring out how it all works. I have been getting stuck a lot, but when you figure it out and get it working, it feels awesome!

            • 3. Re: Bolding single line in datagrid
              jsevlie Level 1
              Peter, your code worked perfectly. Thanks for the help.
              • 4. Re: Bolding single line in datagrid
                peterent Level 2
                If you have a small amount of data and know how you want it to look, based on the row # instead of the data, you might also consider using a Grid container and building the GridRows using a Repeater or just using Flex Builder 2 design mode.