Announcement

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

    ListGrid.setDefaultFields

    SmartClient Version: SNAPSHOT_v9.1d_2013-12-17/PowerEdition Deployment (built 2013-12-17)

    IE-8

    After upgrading from SmartGWT 2.x to 4.x I am now seeing 2 error messages when I bring up a ListGrid:

    Error 1 - Cannot change configuration property 'overflow' to auto now that component isc_ListGrid_2 has been created.

    Error 2 - Uncaught exception escaped: java.lang.IllegalStateException
    Cannot change configuration 'overflow' to auto now that component isc_ListGrid_2 has been created. See the Development console log for details.
    Register a GWT.setUncaughtExceptionHandler(...) for custom uncaught exception handling.

    In my Dev console, I see:
    15:09:08.917:WARN:ListGrid:isc_ListGrid_2:ListGrid initialized with this.fields attribute set to an array containing fields which are already being displayed in another ListGrid instance. To reuse standard field configuration across multiple ListGrids, use listGrid.defaultFields rather than assigning directly to listGrid.fields.

    Everything works in SmartGWT 2.x, but these two popup errors are appearing in the same code under SmartGWT 4.x.

    In the Javadoc for ListGrid.setDefaultFields(), I'm a bit confused by the writeup. Hopefully I can get some clarification here. The first paragraph reads:

    An array of listGrid field configuration objects. When a listGrid is initialized, if this property is set and there is no value for the fields attribute, this.fields will be defaulted to a generated array of field objects duplicated from this array.

    Does this mean if there is no datasource added to the ListGrid (providing DataSource fields) then use ListGrid.setDefaultFeilds() for an array of shared common Component fields (ListGridField)?

    #2
    SmartGWT is calling out usage issues in your code. They would cause problems in 2.x, but weren't caught and warned about in that version.

    ListGrid.defaultFields provides a default for ListGrid.fields when fields are not specified. If the array of fields comes from defaultFields, it still overlays the DataSource fields in exactly the same way.

    Comment


      #3
      Is there any sequence specific usage for setDefaultFields? Should it be set before assigning the datasource?

      Comment


        #4
        It can't be called after the ListGrid is drawn or has been asked to fetch data.

        Comment


          #5
          OK. The message in the DEV console talks about reusing ListGridFields in other ListGrids, which is exactly what I am doing. So if I have an array of ListGridFields that will be reused in a ListGrid and a TreeGrid, I would want to use setDefaultFields in both ListGrid and TreeGrid from the same array of ListGridFields?

          And then later when I want to change layout and attributes of the fields I would call getFields() and make the changes and then use setFields() with the changes?

          The ListGrid/TreeGrid will clone the ListGridFields in defaultFields when getFields() is called?

          Comment


            #6
            setDefaultFields() will clone the fields so you don't have to create separate objects across different grids.

            It's never valid to call listGrid.getFields() and use the returned objects in another grid.

            Comment


              #7
              Oh yes, I agree, I mean I would use getFields() and reuse those fields in the *same* grid, not in another grid.

              I think I got the concepts, thank you for the explanations.

              Comment


                #8
                I'm trying to set ListGrid.setDefaultFields() and I'm getting this error? Is there a sequence of when setDefaultFields should be set?

                java.lang.IllegalStateException: Cannot change configuration property 'defaultFields' to [Lcom.smartgwt.client.widgets.grid.ListGridField;@45bbe2 now that component isc_PivotTableGrid_5_0 has been created.

                Comment


                  #9
                  Please see post #4 above.

                  Comment


                    #10
                    I set 405 fields into ListGrid.setDefaultFields() and then when I call ListGrid.getFields() from the same grid, I only get 1 field back?
                    Last edited by JLivermore; 6 Feb 2014, 06:04. Reason: more detail

                    Comment


                      #11
                      That would happen if you also setFields() with one field. Also, you would expect no fields if you call getFields() before drawing or some other operation (like fetchData()) forced the fields to be computed.

                      If you think you're seeing an actual bug, please let us know how it can be reproduced.

                      Comment


                        #12
                        Would it be too much to ask for a simple example?

                        Comment


                          #13
                          An example consisting of.. a call to setDefaultFields()?

                          Comment


                            #14
                            An example using 2 Grids with the same default fields. I would be interested in:

                            1. The ordering in which to use setDefaultFields()
                            2. Using getFileds() to manipulate the display and order of the fields between fetchData() calls.

                            I seem to be having difficulty getting this setup correctly coming from SmartGWT 2.x to SmartGWT 4.x. What was working before, now has a lot more restrictions and that is where my confusion lies.

                            Comment


                              #15
                              We can't really create a sample, because we're not clear on why you think you need to call setDefaultFields(). You can always simply call setFields() instead, you just have to make sure that each instance is creating a set of fields (calling new ListGridField()) rather than doing something like re-using an Array of ListGridField stored in a static variable.

                              Comment

                              Working...
                              X