Date column not showing date picker when editing unless type is 'date' but...

Date column not showing date picker when editing unless type is 'date' but...

cj1005cj1005 Posts: 142Questions: 45Answers: 1

Hi All,

With the help of Kevin, I recently integrated moment.js into my web app, this is to get the searchBuilder plug-in working with my date format DD/MM/YYYY, this is working well but I've hit a snag:

I have two date columns ("Last Edit" and "Deleted"), both with the type "date".

When I edit one of these dates, I get the date picker and the date is updated correctly, but any data in the other date column is removed. I checked my ajax logs and the "other" date column is submitted as blank (even though it is not blank).

As a test, I removed the type "date" (defaulting to type "string") from both of these date columns and the data now updates correctly, but the date picker no longer appears when editing these columns or when trying to use them with the searchBuilder.

So, I need to either solve why the data is not submitted for the "other" date columns or I need a way to show the date picker by detecting the date format within the columns.

Any advice\suggestions, please?

Cheers, Chris

Replies

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @cj1005 ,

    This is not something I have seen before. Could you please link to a test case? I think that will be necessary to actually see what is going on here.

    Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Thanks,
    Sandy

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Thanks Sandy, I will send over an example asap

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Hi Sandy, sorry for the slow response.

    I've set up a test page, so please go to:

    https://www.wd4g.com/WCGateway/WDLogin.wc

    Login details:
    DTUSERS (same for un and ps)

    Once logged in, click 'Car List' to load the test screen.

    If you edit one of the 'Last Edit' or 'Deleted' columns, this will work, but if you subsequently edit the other column afterward you will notice the date in the first column you edited has been removed.

    I pass the data up (within Ajax) in the format DD/MM/YYYY I'm starting to think I need to send it in the default format and then render the data in the above format, do you think this might help?

    Thank you for looking into my issue, much appreciated.

    Cheers, Chris

  • allanallan Posts: 63,230Questions: 1Answers: 10,416 Site admin

    Hi Chris,

    Since you have Moment on the page already, I would suggest that you should use the datetime input type rather than date. The former allows formatting control so we can do:

      type: 'datetime',
      format: 'DD/MM/YYYY'
    

    And that will let the form correctly populate with the value - show a date picker widget and also submit it to the server in that format.

    Allan

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Thank you Allan, that has fixed the submitting issue as well as fixing another issue which is the date not being shown when editing :smile:

    But, weirdly the SearchBuilder no longer works for the 'Last Edit' and 'Deleted' columns although it does work for the 'Date of Entry' column as far as I can see all 3 columns are set up the same, the only difference is the 'Date of Entry' column is not editable.

    Any ideas?

    Thank you, Chris

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Actually, it appears all 3 columns no longer work with the SearchBuider :neutral:

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @cj1005 ,

    In your datatables initialisation, you are setting the column type for those columns as follows...

    columnDefs: [
        
         { targets: [6], type: "date-eu"},
            
         { targets: [7], type: "date-eu"},
    
    ], 
    

    Try setting the column types to be 'moment-DD/MM/YYYY'. Then it will be in a format that SearchBuilder can understand and get the format from.

    The code where it does this can be found here.

    Hope this helps,
    Sandy

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Thank you so much :smiley:

This discussion has been closed.