jQWidgets Forums

jQuery UI Widgets Forums Grid Uncaught TypeError: Cannot call method 'focus' of undefined

This topic contains 6 replies, has 2 voices, and was last updated by  cberube 11 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author

  • cberube
    Member

    Although, the functionality works, the library is trowing an error when updating cells containing a Dropdownlist. The method its does conversions and updated a couple fields fields.

    The error occurs when I click on another field.

    cellvaluechanging: function (row) {
    prt.emp.setValResults(row);
    },

    What can cause this error? Thanks in advance for your collaboration.

    text: ‘Customer First’, datafield: ‘v1’, width: ‘10%’, align: ‘center’, cellsalign: ‘center’, columntype: ‘dropdownlist’,
    createeditor: function (row, value, editor) {
    editor.jqxDropDownList({ source: empType1.records, displayMember: ‘label’, valueMember: ‘value’ });
    },
    cellvaluechanging: function (row) {
    prt.emp.setValResults(row);
    },
    initeditor: function (row, value, editor) {
    var EJC = $(‘#empGrid’).jqxGrid(‘getcellvalue’, row, “EJC”);
    if (prt.emp.isEmpType2(EJC)) {
    editor.jqxDropDownList({ source: empType2.records, displayMember: ‘label’, valueMember: ‘value’ });
    }
    }


    Peter Stoev
    Keymaster

    Hi cberube,

    I suppose that could be related to the custom code inside the “cellvaluechanging” callback function. Could you provide a more complete sample?

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    cberube
    Member

    Hi Peter,

    I found another way of doing it which makes the error disappear. This also updates the field value in order to get the right value in the setter function. There was a delay and I was getting he previous value.

    cellendedit: function (row, editor) {
    var newVal = $(‘.jqx-dropdownlist-content’).find(‘span’).eq(‘0’).text();
    $(‘#empGrid’).jqxGrid(‘setcellvalue’, row, “v1”, newVal );
    prt.emp.setValResults(row);
    },

    Lets me know if that makes sense.

    Thanks,


    Peter Stoev
    Keymaster

    Hi cberube,

    According to me, it would be better if you use the jqxDropDownList’s API for getting its Label and/or Value,. For example, jqxDropDownList has a method called “getSelectedItem” which returns an Object with Key/Value pairs or null if there’s no selected item. The label and value keys are “label” and “value” i.e var label = item.label; and var value = item.value;

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    cberube
    Member

    Finally the error is back. here is the setValResults() function.

    prt.emp.setValResults = function (row) {
    var empGrid = $(“#empGrid”);
    var cRow = empGrid.jqxGrid(‘getrowdata’, row);
    var newVLR = prt.emp.setVLR(cRow);
    var newTTR = prt.emp.setTTR(cRow);
    empGrid.jqxGrid(‘beginupdate’);
    empGrid.jqxGrid(‘setcellvalue’, row, ‘VLR’, newVLR);
    empGrid.jqxGrid(‘setcellvalue’, row, ‘TTR’, newTTR);
    empGrid.jqxGrid(‘endupdate’);
    };


    Peter Stoev
    Keymaster

    Hi cberube,

    The problem is actually that you try to update the Grid while your editor is still opened. That is wrong as an approach. If you want to update a full row, use the “updaterow” method, but make sure that there is no opened editor anymore i.e in the “cellendedit” event handler.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    cberube
    Member

    Tried editor.jqxDropDownList(“close”); But editor is the fieldName.

    Do you have an example on how the get a handle on the editor instance.

    Thanks,

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

You must be logged in to reply to this topic.