Avoid datepicker focus upon editing

Avoid datepicker focus upon editing

natrabisnatrabis Posts: 3Questions: 2Answers: 0
edited October 2020 in Free community support

I have a datepicker field in the editor which, upon edit is immediately put on focus when I want the user to select the fiel he wants to update.

My editor code:

var editor = new $.fn.dataTable.Editor( {
        ajax: 'php/table.psp_settlements.php',
        table: '#psp_settlements',
                fields: [
            {
                "label": "Date:",
                "name": "Date_created",
                "type": "datetime",
                "format": "DD-MM-YYYY"
            },
            {
                "label": "PSP:",
                "name": "PSP",
                "type": "select",
                "options": [
                    "aaaa",
                    " yyy",
                    " bbb",
                    " ccc",
                    " ddd",
                    " Iee"
                ]
            },
            {
                "label": "Amount:",
                "name": "Amount"
            },
            {
                "label": "Currency:",
                "name": "Currency",
                "type": "select",
                "def": "EUR",
                "options": [
                    "EUR",
                    "USD",
                    "ZAR"
                ]
            },
            {
                "label": "Amount USD:",
                "name": "Amount_USD"
            },
            {
                "label": "Account:",
                "name": "account",
                "type": "select",
                "def": "AR",
                "options": [
                    "AR",
                    "RR"
                ]
            },
            {
                "label": "Memo:",
                "name": "Memo",
                "type": "textarea"
            },
            {
                "label": "Date_Import:",
                "name": "date_import"
            },
            {
                "label": "Reference:",
                "name": "Reference"
            }
        ]
    } ); 

How can i avoid this behavior?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You can set focus to 'none' in the form-options to prevent that - see example here,

    Colin

  • loukinglouking Posts: 259Questions: 52Answers: 0

    @colin - the referenced example now throws a js error and doesn't show editor controls. Is there a new solution to this?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Ah, yep, Editor 2.0 needs different files included - see example updated here. The code is the same as before, just the includes are different.

    Colin

  • loukinglouking Posts: 259Questions: 52Answers: 0

    Thanks. I only ask because I'm still seeing the calendar popup on my code. (And by the way the docs say to use null not 'none', but both give similar result for me for my datepicker.) I'll try to reproduce this in a fiddle and post a new question. I'm guessing it might have to do with my use of jquery ui, but that's pure speculation at this point.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Ah, yep, if you be none, you're correct, I've updated my example. And yep, if you can demonstrate that in a test case, we're happy to take a look,

    Colin

Sign In or Register to comment.