Announcement

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

    Is it possible to redraw the items in a combobox after it is drawn?

    Hi, i have a custom row formatter in a combobox that i create like so:
    Code:
     ListGrid pickListProperties = new ListGrid();
    pickListProperties.setCellFormatter((value, record, rowNum, colNum) -> {      
        String a = record.getAttribute(FIELD_A);    
        String b = record.getAttribute(FIELD_B);      
        return a + (b != null ? " (" + b + ")" : ""); });
    
    myCombobox.setPickListProperties(pickListProperties);
    My question is, is it possible to change the cellformatter of the pick list and have the combobox redraw all items in the picklist at a later time? I want the formatting in the combobox to change depending on some server value.

    I tried calling setPicklistProperties again, and also redraw() on the combobox after changing the properties, but nothing worked.

    Smartgwt 6.0, december 2017.

    #2
    Trying to call setPickListPropeties() a second time won’t work (as doc’d) but you don’t need to - just write the formatter function so it changes behavior once the data is available.

    Comment


      #3
      Well, that's what i stared out doing, but i'm not sure i explained myself clearly enough. My problem is that the comcobx item renderer is based on some value outside the underlying data. The underlying data has not changed, but another data, which is related but not backed by the datasouece, has.

      Let me give a stupid example:

      Say i have a comcobox with users. i want each name to be formatted like this:
      Code:
       
       return firstName + " " + lastName + " >>> " + myCounter;
      And let's say that "myCounter" is an int that i increase every time a button is clicked.

      How do i tell my databound combobox, that has already been rendered (since the user has clicked on it to look at the elements in it, and they were fetched from the server etc.), to re-render all the strings in it.

      I tried redraw() on the combobox which as i mentioned didn't work.

      Comment


        #4
        Your formatter affects the pickList so that’s what would need to be redrawn if there is some kind of data change going on outside of the comboBox data.

        Comment


          #5
          Yes, but how do i trigger the picklist redraw? I can't find any way to get at the picklist via the combobox? When the "myCounter" above has changed, i want to trigger the CellFormatter for each row in the picklist and have the picklist redraw itself, but i cannot find any way to do it.

          Comment


            #6
            You have pickListProperties which you are already using to install your formatter. In the context of your formatter, or other APIs you could hook via pickListProperties, the pickList is simply "this".

            Comment

            Working...
            X