jQWidgets Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: createeditor vs. initeditor createeditor vs. initeditor #65856

    jbuwidgets
    Participant

    UPDATE:

    While experimenting, I noticed that when I use columntype: 'datetimeinput' it works as expected (meaning createeditor is only called once), but when I use columntype: 'textbox' then createeditor fires every single time I go into edit mode. Perhaps a defect with textbox?

    in reply to: createeditor vs. initeditor createeditor vs. initeditor #65854

    jbuwidgets
    Participant

    So if createeditor is called once then why am I getting the following javascript console output when I run the sample code?

    
    createeditor
    initeditor
    createeditor
    initeditor
    createeditor
    initeditor
    

    jbuwidgets
    Participant

    Excellent, just what I was looking for!

    I do have a couple of quick follow-up questions on this portion of your code:

    var initeditor = function (row, cellvalue, editor, celltext, pressedChar) {
                    if (pressedKey == '-') {
                        editor.val('-');
                        setTimeout(function () {
                            editor[0].setSelectionRange(1, 1);
                        }, 100);
                    }
                    pressedKey = null;
                };

    1) why use setTimeout() instead of just setting the editor’s value?
    2) why use editor[0].setSelectionRange(1, 1); instead of editor.setSelectionRange(1, 1);? Why is the index [0] needed?

    Thanks again.

Viewing 3 posts - 1 through 3 (of 3 total)