Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: table sorting not working for date column

modadvisor free asked 3 years ago


date column sorting not working.

my date format is MM/DD/YYYY when i click on header it sorts with month only not considered day and years. please let me know how can i do it ?

          {
                label: "From",
                field: "eff_date",
                datepicker: true,
                sorting : true                    
            }

please guide me the modification required. Thanks


frankvdsm priority answered 3 years ago


First of all: make sure taht the date in your datasource table is in the format YYY-MM-DD.

Don't apply the format to your datatable but create a function like this:

public showTimestamp(n: string) {

let y = n.substr(0,4);

let m = n.substr(5,2);

let d = n.substr(8, 2);

return d + "/" + m + "/" + y; }

in your HTML us this function like this:

{{ showTimestamp(v.datum) }}

Your data is always shown in the right format and is also shown sorted correctly.

Regards, Frank


Mikołaj Smoleński staff commented 3 years ago

@modadvisor were @frankvdsm tips helpful?

Keep coding,  Mikołaj from MDB


modadvisor free commented 3 years ago

i am using mdb vue data table within data table how i can call your function ?


Mikołaj Smoleński staff commented 3 years ago

I guess @frankvdsm fix is applicable only in MDB5. In MDB4 datatable there is no other option than changing date format to YYYY/MM/DD.

Keep coding,  Mikołaj from MDB



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: MDB4 6.7.2
  • Device: PC
  • Browser: chrome
  • OS: windows 10
  • Provided sample code: No
  • Provided link: No