Announcement

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

    Is there a way to re-instantiate a listGrid - SmartClient_v120p_2019-04-13_Evaluation

    In a listGrid, I am using myListGrid.setFields(newFields) in the data arrived: callback to manipulate column headings. The underlying data is manipulated (add/deleted) using another Tab which invalidates the columns that are currently being displayed.

    As per the API docs: " ListGrid.setFields(newFields) - Sets the fields array and/or field widths to newFields and sizes, respectively. If newFields is specified, it is assumed that the new fields may have nothing in common with the old fields, and the component is substantially rebuilt. Furthermore, it's invalid to modify any of the existing ListGridFields after they've been passed to this function."

    Since it is invalid to modify existing fields, it seems that I would need to re-instantiate the listGrid so that the columns will be recalculated based on the current data.

    How would I go about doing this?

    I have tried assigning the listGrid to a var, and nulling out the var to destroy the existing listGrid, and then re-assigning, but this does not work.
    Code:
    var prodLG = isc.ListGrid;
    prodLG.create(listGridParms);
    Code:
    prodLG = null;
    prodLG = isc.ListGrid;
    prodLG.create(listGridParms);
    Code:
    Component Hierarchy
    <DataView>
      <TabSet>
        <VLayout>
          <myListGrid>
    I am currently reloading the html page as a workaround. There must be a better way to handle this. What is the magic incantation?

    #2
    If you just need to change field titles and show/hide fields, just use setFieldTitle() and showField()/hideField() APIs.

    If the fields are changed in several ways where it’s difficult to be incremental, calling setFields() can still make sense. To make sure the fields you pass in are new, just create them in a method both the first time and subsequent times, with different parameters expressing whatever differences are necessary.

    Finally, you can replace the entire grid, but just assigning to a Java variable won’t do it. destroy() the original ListGrid, and add the new grid to same parent via addMember().

    Comment


      #3
      In my circumstance I am forced to use setFields().

      The magic destroy() incantation worked well and solved my problem ;-)...

      Thank you!!

      Comment

      Working...
      X