Announcement

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

    "Group By" State of ListGridField is still maintained even after "Ungroup"

    Hi Isomorphic,

    We are using Smart Gwt-4.1p (10th August 2015)
    Browser: Google chrome 45.0.2454.101 m

    Issue : "Group By" State of ListGridField is still maintained even after "Ungroup".

    I have attached the sample code (TestsmartGwtProject.java) for your reference.

    Sample code will display ListGrid with 4 columns(Code,Country,Capital,Government) and it is having the code for the addFieldStateChangedHandler() of ListGrid to save the viewstate.

    Steps to Reproduce:

    1. Run the Sample code and Sort any one column,let us say "Code".
    2. Open context menu and Group the "Code" Column and Ungroup it.
    3. Now refresh the browser and Check

    Expected : "Code" Column should be displayed without Grouping.

    Actual : "Code" Column should be displayed with Grouping.

    Note : This issue is observed only when sorting is applied to any one of the column.

    I have attached the screenshot(ViewState_of_ListGrid_Column.png) for your reference.

    Thank you.
    Attached Files

    #2
    The problem here is that you're using the "FieldStateChanged" notification to store out the viewstate - but the grouping state is not part of the field-state - it's separate, and as such will not fire the field-state-changed notification when the user groups / ungroups the grid.
    Try using the "ViewStateChanged" notification instead - like this:
    Code:
            changeLogGrid.addViewStateChangedHandler(new ViewStateChangedHandler () {
    
                @Override
                public void onViewStateChanged(ViewStateChangedEvent event) {
                    Offline.put(getId(),changeLogGrid.getViewState());    
                    
                }});

    Comment


      #3
      Hi vnathank,

      please note that there is not only addFieldStateChangedHandler() in ListGrid, but also addGroupStateChangedHandler(), addSelectionChangedHandler(), addSortChangedHandler() and addHilitesChangedHandler.
      You'll need to also implement some of the other ones, but definitely addGroupStateChangedHandler(). Perhaps you wanted addViewStateChangedHandler instead.

      FieldStateChangedHandler docs say:
      Notification method executed when columns are resized or reordered, or fields are shown or hidden.
      Best regards
      Blama

      Comment


        #4
        Crosspost...
        Isomorphic: I'm using addViewStateChangedHandler() in my code, but use it only to persist FieldState- and SortState-changes right now. Would you suggest to rewrite the code and use only those handlers where the data is actually persisted? What is the penalty of triggering this all the time (e.g. when clicking a row, because then the selection changed)?

        Best regards
        Blama

        Comment

        Working...
        X