Announcement

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

    Grouping order in list grid

    SmartClient Version: v9.1p_2014-05-18/PowerEdition Deployment (built 2014-05-18)

    Hi,
    is ther a way to custom sort the groups in a ListGrid ? SortNormalizer won't work. Only SortSpecifier with SortDirection seems to change the order.

    Code:
    		caseListGrid = new ListGrid();		
    			caseListGrid.setAutoFetchData(true);	
    			caseListGrid.setShowFilterEditor(true);
    			caseListGrid.setDataFetchMode(FetchMode.LOCAL);
    			caseListGrid.setAlign(VerticalAlignment.CENTER);
    			caseListGrid.setHeaderHeight(45);
    			ListGridField name = new ListGridField(CaseModel.NAME, "Name");	
    			name.setAlign(Alignment.LEFT);
    			ListGridField manager = new ListGridField(CaseModel.MANAGER, "Manager");
    			manager.setAlign(Alignment.CENTER);
    			ListGridField openDate = new ListGridField(CaseModel.OPEN_DATE, "Open date", 90);
    			openDate.setAlign(Alignment.CENTER);
    			//ListGridField archiveDate = new ListGridField(CasesDS._archiveDate, "Archive Date");
    			ListGridField closeDate = new ListGridField(CaseModel.CLOSE_DATE, "Close date", 90);
    			closeDate.setAlign(Alignment.CENTER);
    			ListGridField numberOfDocs = new ListGridField(CaseModel.NUM_OF_DOC, "No. of entries", NUMBER_VALUE_CLUMND_WIDTH);
    			numberOfDocs.setWrap(true);
    			numberOfDocs.setAlign(Alignment.CENTER);
    			ListGridField documentDateRange = new ListGridField(CaseModel.DOC_DATE_RANGE, "Document date range");
    			documentDateRange.setAlign(Alignment.CENTER);
    			ListGridField numOfQueries = new ListGridField(CaseModel.NUM_OF_QUERIES, "No. of Queries", NUMBER_VALUE_CLUMND_WIDTH);
    			numOfQueries.setWrap(true);
    			numOfQueries.setAlign(Alignment.CENTER);
    			ListGridField internalExports = new ListGridField(CaseModel.INTERNAL_EXPORTS, "Internal Exports", NUMBER_VALUE_CLUMND_WIDTH);
    			internalExports.setWrap(true);
    			internalExports.setAlign(Alignment.CENTER);
    			ListGridField numberOfAssignemtns = new ListGridField(CaseModel.NUM_OF_ASSIGNEMNTS, "No. of members", NUMBER_VALUE_CLUMND_WIDTH);
    			numberOfAssignemtns.setWrap(true);
    			numberOfAssignemtns.setAlign(Alignment.CENTER);
    			ListGridField status = new ListGridField(CaseModel.CASE_STATUS_LABLE, "Status");
    			status.setSortNormalizer(new SortNormalizer() {
    				
    				@Override
    				public Object normalize(ListGridRecord record, String fieldName) {
    					//System.err.println(record.getAttribute(CasesDS.NAME) + record.getAttribute(CasesDS.CASE_STATUS));
    					String status = record.getAttribute(CaseModel.CASE_STATUS);
    					if (status != null) {
    						switch (CaseStatusC.valueOf(status)) {
    						case NEW:
    							return 5;
    						case OPEN:
    							return 4;
    						case REOPENED:
    							return 3;
    						case DISCOVERY_CLOSED:
    							return 2;
    						case CLOSED:
    							return 1;
    						default:
    							break;
    						}
    						
    					}
    					return 1;
    				}
    			});
    			status.setHidden(true);
    			
    			caseListGrid.setFields(name, manager, openDate,
    					closeDate, numberOfDocs, documentDateRange,
    					numOfQueries, internalExports, numberOfAssignemtns, status);
    			caseListGrid.setInitialSort(
    					new SortSpecifier(CaseModel.CASE_STATUS_LABLE, SortDirection.DESCENDING));
    			caseListGrid.setGroupStartOpen(GroupStartOpen.ALL);
    			
    			caseListGrid.setFilterLocalData(true);			
    			caseListGrid.groupBy(CaseModel.CASE_STATUS_LABLE);

    #2
    Hi El Thomaso,

    please see this thread where I asked a similar question.
    I did not try the solution, yet.

    Best regards,
    Blama

    Comment


      #3
      See also a new property in 10.0 listGrid.sortByGroupFirst which allows sorting by the grouped fields instead of by the current sort on the grid as a whole.

      Comment


        #4
        Hi Isomorphic,

        I just read ListGrid.getSortByGroupFirst(). Sounds like a great addition.
        Does this also affect server fetches?

        Best regards,
        Blama

        Comment


          #5
          Thank you,
          I will try the 10v.
          The suggestion from Isom. in Blama's post, does not work for me. Im finding the group nodes in the sortNormalizer and returning different values for them (In my desired order) But it seems it still sorting only ASC or DESC.

          Comment

          Working...
          X