datetime-moment plug not working correctly with locale

datetime-moment plug not working correctly with locale

erwin16erwin16 Posts: 14Questions: 5Answers: 1

I am trying to sort diatomite columns as per diatomite plugin documentation, but using international formats

$(document).ready(function() {

$.fn.dataTable.moment( 'LL', locale );
$.fn.dataTable.moment( 'L h:mm', locale ); 

I have the following defaults :

var langUrl = "//cdn.datatables.net/plug-ins/be7019ee387/i18n/French.json";
if (locale === "en") { langUrl = "//cdn.datatables.net/plug-ins/be7019ee387/i18n/English.json"; }
moment.locale(locale);

$.extend( true, $.fn.dataTable.defaults, {
   dom: "<'row'<'col-xs-6'><'col-xs-6'f>r>t<'row'<'col-xs-6'l><'col-xs-6'p>>", 
   language: { url: langUrl },
  searching: true,
  ordering: true,
  paging: true,
  info: false,
 select: true

} );

but sorting the date column doesn't gives the expected result....

Answers

  • allanallan Posts: 61,938Questions: 1Answers: 10,157 Site admin

    Can you please link to a test case, as per the forum rules, so we can debug the issue.

    Allan

  • erwin16erwin16 Posts: 14Questions: 5Answers: 1

    Hi Allan , thanks for replying ..
    I'll close this issue as I found the error.. I was not using diatomite-moment correctly ...

    I am now using

       columnDefs: [ 
              targets: column_date,
              render: function ( data, type, full, meta ) {
                if(type === 'display'){
                  if(data){
                    var mDate = moment(data);
                    return (mDate && mDate.isValid()) ? mDate.format("LL") : "";
                  }
                }
                return data;
              }
            }
          ]
    

    and it works perfectly... error was return "" at the end....

This discussion has been closed.