Announcement

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

    overriding createRecordComponent.

    Hey guys.

    I'm using the ListGrid. And I'm setting widgets into the cells. Like
    http://www.smartclient.com/smartgwt/showcase/#featured_grid_cell_widgets

    I'm inserting a Label in each cell with some ClickEvents to open a popupForm

    THE PROBLEM:
    1. How can I tell the ListGrid NOT TO call the toString method?. I'm setting the text that I need to show in the Label, but behind the label, I can see the text coming from the grid trying to show the value of the cell.
    Since the object that I'm showing in each cell is a CUSTOM OBJECT THAT EXTENDS ListGridRecord, for now, I did a @override toString method that returns " ". But that's not a final solution.

    2. (THE MOST IMPORTANT)
    The Listgrid is printing a "[object Object]" message in each label. And I HAVE NO IDEA WHERE IS THIS COMING FROM.
    ANY IDEAS? THIS IS DRIVING ME CRAZY.

    sample code:

    #2
    Widget can appear either next to or in lieu of a value (see recordComponentPosition). Use a CellFormatter that return always returns " " if you want to omit the value.

    Comment


      #3
      Originally posted by Isomorphic
      Widget can appear either next to or in lieu of a value (see recordComponentPosition). Use a CellFormatter that return always returns " " if you want to omit the value.
      thanks for the replay. but end up in the same spot.

      1. By default, ListGrid calls the toString method of ListGridRecord object right?
      SO, How can I tell the ListGrid NOT TO call the toString method?

      2. The Listgrid is printing a "[object Object]" message in each label (THIS IS, BESIDE THE TOSTRING() CALL. BY NOW, I HIDE THE TOSTRING() PRINT BY OVERRIDING THE METHOD AND RETURNING " ").
      I HAVE NO IDEA WHERE IS THIS COMING FROM.

      ANY IDEAS?

      Any one? please.

      I NEED TO TURN THESE TWO PRINTS OFF, SO I CAN MANUALLY USE THE LABEL.SETCONTENT THAT I'M INSERTING IN EACH CELL.

      THANKS A LOT

      Comment


        #4
        ? Please re-read: CellFormatter is the answer, as we just explained.

        Comment


          #5
          Wow, that was a short answer. But searching for the CellFormatter in google I found some example code that help me. At least I found a "north" for my solution here.

          Because the documentation for CellFormatter is less that vague.
          http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/CellFormatter.html

          Anyways, if anyone is trying to use the ListGrid with a home made Object, this is what you need to do to print what you want in each cell.


          ListGridField rentField = new ListGridField("rent", "Rent");
          rentField.setCellFormatter(new CellFormatter() {
          @Override
          public String format(Object value, ListGridRecord record, int rowNum,int colNum) {
          return ((Payment) value).getAmount();
          }
          });

          Comment

          Working...
          X