1 Reply Latest reply on Nov 30, 2006 11:53 AM by ur_dtrain

    Highlighting Single Character : DataGrid

    lieut_data
      Greetings!

      Fairly new to this wonderful world of Flex, so apologies if this is trivial.

      I've written a custom data source that parses JSON data from an existing web service -- among other things, the data returned includes the column that is sorted (sorting occurs on the server), and a highlight index for each row to indicate which character of the sorted column for that row was the basis by which the sorting took place.

      I'd like to highlight that character in some way. I've had good success in creating a custom itemRenderer, and overriding the set text function to call setTextFormat on the appropriate range, at least with a static highlight value. I'm now looking to tie the highlight to the real value returned by the dataset.

      This is sort of an advanced labelFunction question -- in the sense that I want to take the value of one column (on a row by row basis) and use it to compute the value of another that is displayed -- except I don't want to change the value, but rather how it is displayed. (labelFunction doesn't seem to be able to let me do that).

      Besides passing around the data_source to every custom itemRenderer, and basically destroying any hope for clean encapsulation, does anyone have a suggestion on how to achieve the aforementioned?

      Any input whatsoever appreciated!
        • 1. Highlighting Single Character : DataGrid
          ur_dtrain Level 1
          If you've got the unique character for each row, I'd use string utilities in conjunction with the htmlText property of a Label itemRenderer:

          this.htmlText = String(data.thisText).split(data.splitChar)[0]+"<b>"+data.splitChar+"</b>"+String(data.th isText).substr(String(data.thisText).indexOf(data.splitChar),String(data.thisText).length- 1);

          Some of the syntax above might be a little messy, and the actual index numbers might need adjustment, but you should get the idea.