Results 1 to 4 of 4

Thread: Datefield updates ignored when there is a custom convert method

  1. #1
    Sencha User
    Join Date
    Aug 2014
    Posts
    21
    Vote Rating
    2
      0  

    Default Answered: Datefield updates ignored when there is a custom convert method

    Here's my use case:

    I have a server which returns date on the "YYYY-MM-DD" format, including the "0001-01-01" value when a field is empty.
    I want to show it in the "DD/MM/YYYY" format.

    A test fiddle:
    https://fiddle.sencha.com/#fiddle/i66

    - My dataFormat and convert function are properly set.
    - The format and submitFormat of the editor are set.
    - I even checked the dirtychange event, and the field is set dirty when using the cell editing plugin.

    BUT, there is no call to the update api in the store, here to fake_script, when changing the values in the editor.

    It does work when I remove the convert method in the date field.

    I'm using Ext 5.1.0

  2. Quote Originally Posted by pgarlaud View Post
    Here's my use case:

    I have a server which returns date on the "YYYY-MM-DD" format, including the "0001-01-01" value when a field is empty.
    I want to show it in the "DD/MM/YYYY" format.

    A test fiddle:
    https://fiddle.sencha.com/#fiddle/i66

    - My dataFormat and convert function are properly set.
    - The format and submitFormat of the editor are set.
    - I even checked the dirtychange event, and the field is set dirty when using the cell editing plugin.

    BUT, there is no call to the update api in the store, here to fake_script, when changing the values in the editor.

    It does work when I remove the convert method in the date field.

    I'm using Ext 5.1.0
    Hi pgarlaud--

    If you remove the "record" arguments from the convert method, it should work. Passing the second argument treats the fields as a calculated field, which are "persist:false" by default. You could also set persist:true directly and it should work.

    http://docs.sencha.com/extjs/5.1/5.1...ta.field.Field

    Also, just for reference, the format argument on the datefield should be "dateFormat", instead of "dataFormat".

    I've included a revised Fiddle showing it working as expected.

    I hope that helps!
    Thanks!
    Joel


  3. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446
    Vote Rating
    186
      0  

    Default

    Quote Originally Posted by pgarlaud View Post
    Here's my use case:

    I have a server which returns date on the "YYYY-MM-DD" format, including the "0001-01-01" value when a field is empty.
    I want to show it in the "DD/MM/YYYY" format.

    A test fiddle:
    https://fiddle.sencha.com/#fiddle/i66

    - My dataFormat and convert function are properly set.
    - The format and submitFormat of the editor are set.
    - I even checked the dirtychange event, and the field is set dirty when using the cell editing plugin.

    BUT, there is no call to the update api in the store, here to fake_script, when changing the values in the editor.

    It does work when I remove the convert method in the date field.

    I'm using Ext 5.1.0
    Hi pgarlaud--

    If you remove the "record" arguments from the convert method, it should work. Passing the second argument treats the fields as a calculated field, which are "persist:false" by default. You could also set persist:true directly and it should work.

    http://docs.sencha.com/extjs/5.1/5.1...ta.field.Field

    Also, just for reference, the format argument on the datefield should be "dateFormat", instead of "dataFormat".

    I've included a revised Fiddle showing it working as expected.

    I hope that helps!
    Thanks!
    Joel


  4. #3
    Sencha User
    Join Date
    Aug 2014
    Posts
    21
    Vote Rating
    2
      0  

    Default

    Hello, would be nice if such a critical behaviour was explained in detail in the doc of convert()! My problem is that I'm using the rec parameter to access a static function of my model class:
    Code:
     public function convert(val, record) {   return record.self.parseDate(val); }
    Any ideas how to simulate this without the second parameter? Thanks for your answer already. PS: `dataFormat` was indeed a typo.

  5. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446
    Vote Rating
    186
      0  

    Default

    Quote Originally Posted by pgarlaud View Post
    Hello, would be nice if such a critical behaviour was explained in detail in the doc of convert()! My problem is that I'm using the rec parameter to access a static function of my model class:
    Code:
     public function convert(val, record) {   return record.self.parseDate(val); }
    Any ideas how to simulate this without the second parameter? Thanks for your answer already. PS: `dataFormat` was indeed a typo.
    You can still use the second parameter, but you'll need to set persist: true explicitly since calculated fields are persist: false by default.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •