jQWidgets Forums

jQuery UI Widgets Forums Grid createeditor vs. initeditor

This topic contains 3 replies, has 2 voices, and was last updated by  jbuwidgets 10 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • createeditor vs. initeditor #65795

    jbuwidgets
    Participant

    Looking at the documentation on this page: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-api.htm

    I see the following quotes:

    initeditor […] This function is called each time an editor is opened.

    createeditor […] This function is called only once – when the editor is created.

    However, if you inspect the console output from the sample below it seems that both of them are being called every time a cell is put in edit mode (for this example, I’m pressing Enter to toggle in and out of edit mode on a cell).

    Am I misunderstanding the documentation?

    Thanks.

    
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title id='Description'>Simple Grid.</title>
        <link rel="stylesheet" href="content/jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="scripts/jquery-1.10.2.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="scripts/jqWidgets/jqxgrid.edit.js"></script>
        <script type="text/javascript" src="scripts/jqwidgets/jqxdata.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var data = new Array();
                var accounts =
                [
                    "Payroll", "Misc Expenses", "Office Supplies"
                ];
                var amounts =
                [
                    "2.25", "1.5", "3.0"
                ];
                for (var i = 0; i < 15; i++) {
                    var row = {};
                    var index = Math.floor(Math.random() * accounts.length);
                    var amount = parseFloat(amounts[index]);
                    row["account"] = accounts[Math.floor(Math.random() * accounts.length)];
                    row["amount"] = amount;
                    data[i] = row;
                }
                var source =
                {
                    localdata: data,
                    datatype: "array"
                };
                var dataAdapter = new $.jqx.dataAdapter(source, {
                    downloadComplete: function (data, status, xhr) { },
                    loadComplete: function (data) { },
                    loadError: function (xhr, status, error) { }
                });
    
                var pressedKey = null;
    
                var initeditor = function (row, cellvalue, editor, celltext, pressedChar) {
                    console.log("initeditor");
                };
    
                var createeditor = function (rowindex, cellvalue, editor, celltext, cellwidth, cellheight) {
                    console.log('createeditor');
                };
    
                $("#jqxgrid").jqxGrid(
                {
                    source: dataAdapter,
                    editable: true,
                    selectionmode: 'singlecell',
                    columns: [
                      { text: 'Account', datafield: 'account', width: 250, initeditor: initeditor, createeditor: createeditor },
                      { text: 'Amount', datafield: 'amount', width: 90, cellsalign: 'right', cellsformat: 'c2', initeditor: initeditor, createeditor: createeditor },
                    ]
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid">
            </div>
        </div>
    </body>
    </html>
    
    createeditor vs. initeditor #65809

    Peter Stoev
    Keymaster

    Hi jbuwidgets,

    createeditor is called once. initeditor is called each time an editor is opened. createeditor is not called every time.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    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
    
    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?

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

You must be logged in to reply to this topic.