Announcement

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

    FIx sorting on a column

    Version: v11.0p_2017-05-26/PowerEdition Deployment (built 2017-05-26)

    I have a listgrid. By default i want the grid to be sorted by a column say A(has same value for multiple records). Now when user applies sort on some other field, i want the sort by A to be retained and then sort it by the selected field. How can i achieve this

    #2
    Hi swatiagarwal

    ​You could try it using a addSortChangedHandler and then modifying the sort there.
    Besides of this, this might also be useful as implicitSort (like it is already happening with grouped-by-columns as sorting-prefix), analogue to implicitCriteria. But that's one for Isomorphic.

    Best regards
    Blama

    Comment


      #3
      Thanks Blama I tried:
      grid.addSortChangedHandler(new SortChangedHandler() {

      @Override
      public void onSortChanged(SortEvent event) {
      SortSpecifier[] sortState = event.getSortSpecifiers();
      SortSpecifier[] newSortState =new SortSpecifier[sortState.length+1];
      newSortState[0] = new SortSpecifier("sortOrder", SortDirection.ASCENDING);
      int i=1;
      for(SortSpecifier state :sortState ){
      newSortState[i] = state;
      i++;
      }
      grid.applySortToData(newSortState);
      }
      });


      This works, but throws below javascript error in console:

      *16:56:28.922:MUP9:WARN:Log:com.google.gwt.core.client.JavaScriptException: (InternalError) : too much recursion
      at Throwable_4_g$(pricebook-0.js)
      at Exception_4_g$(pricebook-0.js)
      at RuntimeException_4_g$(pricebook-0.js)
      at JavaScriptExceptionBase_1_g$(pricebook-0.js)
      at JavaScriptException_2_g$(pricebook-0.js)
      at JavaScriptException_1_g$(pricebook-0.js)
      at wrap_2_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at dispatchEvent_2_g$(pricebook-0.js)
      at doFire_0_g$(pricebook-0.js)
      at fireEvent_4_g$(pricebook-0.js)
      at fireEvent_3_g$(pricebook-0.js)
      at fireEvent_0_g$(pricebook-0.js)
      at setupSortChangedEvent_0_g$/sortChanged_0_g$<(pricebook-0.js)
      at apply_0_g$(pricebook-0.js)
      at entry0_0_g$(pricebook-0.js)
      at entry_1_g$/<(pricebook-0.js)
      at isc_ListGrid_handleSortChanged(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at isc_ListGrid_applySortToData(http://127.0.0.1:8888/pricebook/sc/modules/ISC_Grids.js)
      at applySortToData_0_g$(pricebook-0.js)
      at onSortChanged_2_g$(pricebook-0.js)
      at dispatch_498_g$(pricebook-0.js)
      at dispatch_497_g$(pricebook-0.js)
      at dispatch_0_g$(pricebook-0.js)
      at anonymous()

      Any help on this.

      Comment


        #4
        Well, I assume the handler is called again for your applySortToData(newSortState). Have the handler recognize if the 1st sortBy column is already the one you want to fix sorting on - if so, don't do anything.

        Best regards
        Blama

        Comment


          #5
          Also make sure your code matches the one from the addSetSortHandler()-sample in the docs, obviously.

          Comment


            #6
            Thanks a lot Blama
            This worked .

            Comment

            Working...
            X