Announcement

Collapse
No announcement yet.

How to format [Date] value in list view

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to format [Date] value in list view

    By default [Date] value formatted as [Today] \ [Yesterday] \ [18 May] ... but how to format is always as [18.05.2017] ?
    What shoud be changed in list.js and detail.js (or maybe in other files also) ? Maybe there is an example in some Espo modules ?
    Could some one give a clue.

  • #2
    Hello
    Check date format in system settings (Administration > Settings) and user Preferences. User Preferences are more important

    Comment


    • #3
      Within (Administration > Settings) and user Preferences it is possible only to set a pattern like YYYY-MM-DD, MM/DD/YYYY etc.
      I meant that I'd like to rid of narrations like "Today", "Yesterday" and omissions of the YYYY for the current year - they are made somewhere within Espo, but I count found the place yet :-\

      Actually I added custom field definition
      Code:
      {
        "fields": {
          "start-date": {
            "views": "custom:views/your-entity-type/fields/start-date"
          }  
        }
      }
      And the code (based on "views/fields/date.js"):
      Code:
      Espo.define('custom:views/style-expert-certificate/fields/start-date', 'views/fields/date', function
      
          return Dep.extend({
      
              setup: function () {
                  Dep.prototype.setup.call(this);
              },
      
              stringifyDateValue: function (value) {
                  if (!value) {
                      if (this.mode == 'edit' || this.mode == 'search') {
                          return '';
                      };
      
                      return this.translate('None');
                  };
      
                  return this.getDateTime().toDisplayDate(value);
              }
      
          });
      });
      However it doent make any effects - what did I do wrong ?
      Last edited by igrp; 05-20-2017, 08:51 PM.

      Comment


      • #4
        Hello
        Set in data/config.php 'readableDateFormatDisabled' => true
        Not sure it works for steam

        Comment


        • #5
          Tanya, Thanks a lot, it worked out !!

          By the way is there the way to do the same by for single entity / date field only ?

          Comment


          • #6
            Of course. Set view for your field in entity, field view extends date view (or datetime, depends on what you need). Found all methods using 'readableDateFormatDisabled' in panent view and override this methods

            Comment


            • #7
              Tanya, by the way

              on https://github.com/espocrm/documenta...ustom-views.md

              it says:

              ===
              Custom views for specific fields should be specified in entityDefs section of metadata.

              custom/Espo/Custom/Resources/metadata/entityDefs/YourEntityType.json

              { "fields": { "yourFieldName": { "views": "custom:views/your-entity-type/fields/your-field-name" } } } ===

              shouldn't it be "view" instead ?

              Comment


              • tanya
                tanya commented
                Editing a comment
                Yes, thank you

            • #8
              In case someone need the final code to stop showing TODAY / YESTERDAY short-names:

              Code:
              Espo.define('custom:views/ENTITY/fields/MY-date', 'views/fields/date', function (Dep) {
              
                  return Dep.extend({
              
                      setup: function () {
                          Dep.prototype.setup.call(this);
                      },
              
                      stringifyDateValue: function (value) {
                          return this.getDateTime().toDisplayDate(value);
                      }
              
                  });
              });

              Comment

              Working...
              X