Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid Hilite, Images, and Hyperlinks

    I have the following requirements for a listgrid

    1. Allow cell to be hyperlinked (with a custom click event)
    2. Allow IMAGE to be displayed instead of CELL value if certain conditions are met

    Both are easy if considered separately.

    For #1, I used a custom CellFormatter and simply wrote out a hyperlink tag. It's important that I do this in the Cell Formatter as my hyperlink needs to know the CELL location (row, col) of the cell clicked (so I can add context sensitive information to the link).

    For #2, I used a Hilite (to compare if condition is met) and the setHtmlValue field to replace the cell value with an image tag. I also support setHtmlBefore and setHtmlAfter if they want to show the image along with the value.

    The problem comes when I try to do BOTH. I'm unable to produce a hyperlinked image.

    I like the Hilite functionality because it handles condition assessment for me (i.e. does the field meet the criteria specified).
    I allow my users to set a wide variety of conditions so simply coding the conditions into the CellFormatter is not a viable solution for me (I'd basically have to reimplement the entirety of your hilite functionality in the CellFormatter).

    Question: Is there a handler that I can override that fires for a given cell when the hilite criteria has been met? That would allow me to AUGMENT the cell value rather than REPLACE it. I'm trying to find a way to CONDITIONALLY write an image into my hyperlink that I write in the CellFormatter.

    I'm using SmartGWT 3.0 (Developer Console says
    v8.2p_2013-07-11/Pro)

    #2
    Hi kjmoroney,

    did you already see
    • ListGrid.setShowRecordComponents(true);
    • ListGrid.setShowRecordComponentsByCell(true);
    • @Override
      protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
      String fieldName = this.getFieldName(colNum);
      if ("myfieldname".equals(fieldName))
      return <custom_code>;
      else
      return null;
      }


    Best regards,
    Blama

    Comment


      #3
      Yes, I have used that in other cases, although I hadn't considered it in this case.

      The problem is the conditional nature of the image. I'm trying to leverage the HILITE framework to allow me to decide if a particular cell requires the image. For the given table, I allow the USER to decide what the comparison logic should be (much like the SmartGWT HILITE dialog). Thus, I don't know apriori what the comparison logic would be .... I'd have to implement every possible option within the ShowRecordComponentByCell handler).

      Currently, the HILITE concept couples the COMPARISON nature plus the APPLY nature of the process (i.e. if the COMPARISION is true, then APPLY these elements ... css, format, etc ...)

      I'm trying to determine if is any way to decouple the COMPARISON side from the APPLY side (i.e. allow a handler override that will allow me to write custom APPLY logic when the COMPARISON is true).
      Last edited by kjmoroney; 30 Jan 2014, 12:59.

      Comment


        #4
        Just to let you know, we're discussing the best way to handle this requirement.

        Can you clarify something about your use case - are your end users defining these hilites via the stock hiliteEditor, or via some other UI of your own design that just adds to listGrid.hilites?

        Comment


          #5
          By default hilite HTML modifications (htmlBefore / after and replacementValue) are applied *after* formatting the cell value.

          This essentially means that in your case, the custom formatCellValue which writes out an <a...> tag has no effect at all, and the image will be rendered out instead.

          We've added a new feature to our development codebase - the 4.1d branch - to address this limitation. As of the next nightly build, you can specify an attribute "hiliteHTMLAfterFormat" at either the component or field level. This allows you to determine whether the hilite HTML is applied before or after running your cell formatter. In your usage, you'd want to set this value to false, and then you'd end up with the image HTML (from your hilite), inside the hyperlink tag (from your custom cell value formatter)

          Regards
          Isomorphic Software

          Comment

          Working...
          X