Author Topic: Issue filter  (Read 1671 times)

atmaneuler

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
Issue filter
« on: February 19, 2021, 11:54:23 am »
- I want to filter from date to date but if the value in the column is mm.dd.yy then it will filter correctly, if the value in the column is mm.dd then the filter will be false and no rows to display.
- The returned API is in the form yyyy-mm-dd(Ex: 2020-01-15) and then reformatted
--> Expectation: The column shows only the mm.dd value, but filters correctly
{
        title: 'CS1',
        dataType: 'date',
        dataIndx: 'cs1',
        format: 'mm.dd', //Format mm.dd then filter will be wrong, Format mm.dd.yy then filter will be true. But I just want to display mm.dd and the filter is still correct
        align: 'center',
        valign: 'center',
        hvalign: 'center',
        style: this.styleCell(),
        styleHead: this.styleHead(),
        sortable: false,
        filter: { crules: [{ condition: 'between' }] },
        render: (ui) => this.renderCell(ui),
      },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Issue filter
« Reply #1 on: February 22, 2021, 10:02:48 am »
Currently filtering doesn't work correctly without year in the format, I'm looking into the feasibility to support it in upcoming versions.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Issue filter
« Reply #2 on: February 23, 2021, 06:10:57 am »
Here is the solution for your requirement:

Please use column.render instead of column.format to display dates in 'mm.dd' format.

Code: [Select]
render: function(ui){
return $.datepicker.formatDate("mm.dd", new Date(ui.cellData))
},

Please let me know if it doesn't solve your requirement.

atmaneuler

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Issue filter
« Reply #3 on: February 24, 2021, 12:48:57 pm »
When I add your command to my command line, my grid page doesn't load at the same time with an error message.

Code:
    {
        title: 'CS1',
        // width: 65,
        dataType: 'date',
        dataIndx: 'cs1',
        format: 'mm.dd',
        align: 'center',
        valign: 'center',
        hvalign: 'center',
        style: this.styleCell(),
        styleHead: this.styleHead(),
        sortable: false,
        filter: { crules: [{ condition: 'between' }] },
        render: function(ui) {
          return $.datepicker.formatDate('mm.dd', new Date(ui.cellData))
        }
      },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Issue filter
« Reply #4 on: February 24, 2021, 06:01:09 pm »
In Angular, you would have to add this import.

Code: [Select]
import $ from 'jquery';