Dates for wijmo collection grid

Posted by: samvarth123 on 27 September 2021, 10:09 am EST

    • Post Options:
    • Link

    Posted 27 September 2021, 10:09 am EST

    I want a collection to be displayed with descending order (latest on top).Also ithere is no date that should be on top of the latest date. Using angular 6+ and wijmo flexgrid

  • Posted 29 September 2021, 12:51 am EST

    Hello,

    You may use the sortDescriptions ObservableArray of collectionView and push a new SortDescription with setting ascending to false(making it descending in order) for the date column. You may refer to the API for more information:https://www.grapecity.com/wijmo/api/classes/wijmo.collectionview.html#sortdescriptions

    You may also refer to the sample demonstrating the same:https://stackblitz.com/edit/angular-hwmcuh?file=src%2Fapp%2Fapp.component.ts

    Let us know if that’s works for you.

    Regards

  • Posted 29 September 2021, 8:12 am EST

    Could you suggest me a case where one of the object doesn’t have a date and it needs to be on top and the rest of them should be in descending order.The example you gave is where all of them have a date.My scenario is for one row not having a date and it should be on top and rest of them needs to be in descending order

  • Posted 29 September 2021, 8:23 am EST

    data[5].dateCol = null; Suppose I put this line  
    

    new wjCore.SortDescription(‘dateCol’, false) in https://stackblitz.com/edit/angular-hwmcuh?file=src%2Fapp%2Fapp.component.ts

    the one which doesn’t have date is displaying at bottom and not at top and all in descending order.

  • Posted 30 September 2021, 3:39 am EST

    Hello,

    The value of sortNullsFirst depends upon the useStableSort, if the useStableSort is false, the value of sortNullsFirst cannot be false, except when it is set by default.

    But, the sortNullsFirst will not fulfill your requirements because then the nulls will be sorted first regardless of the sort order. But, you want to sort the nulls at first while sorting in descending order. To achieve this, you will need to handle the sortComparer property of the CollectionView and manually sort the nulls:

    
    this.source.sortComparer = function(a, b) {
      if(a === null) {
    	return 1;
      }
      else if(b === null) {
    	return -1;
      }
    }
    
    

    You can refer to the sortComparer API for more information:https://www.grapecity.com/wijmo/api/classes/wijmo.collectionview.html#sortcomparer

    You may refer to the sample demonstrating the same:https://stackblitz.com/edit/angular-fs4cnd?file=src%2Fapp%2Fapp.component.ts

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels