jQuery UI Widgets Forums Grid 'setcellvalue' is a failure

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 7 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • 'setcellvalue' is a failure #91571

    stevesl
    Participant

    Every bit of this code executes successfully and does exactly what is expected and without error.
    EXCEPT all three of the ‘setcellvalue’

    No I can’t jsFiddle this.

    I use ‘setcellvalue’ in numerous places without this issue.

    var tkopn = j.TkoPartNo;
    var bGrid = $(‘#jqxBOMGrid’).jqxGrid(‘getrows’);

    for (var i = 0; i < bGrid.length; ++i) {
    console.log(“i”, i, bGrid[i].TkoPartNo, tkopn, bGrid[i].TkoPartNo == tkopn, j.Qty, typeof(j.Qty), “//” + j.Qty.toString() + “//”);
    if (bGrid[i].TkoPartNo == tkopn) {
    var rowID = $(‘#jqxBOMGrid’).jqxGrid(‘getrowid’, i);
    if (j.Qty == “”) {
    $(‘#jqxBOMGrid’).jqxGrid(‘deleterow’, rowID);
    } else {
    var qty = ” + j.Qty
    var x = $(‘#jqxBOMGrid’).jqxGrid(‘getcellvalue’, i, ‘QtyPreEdit’);
    console.log(rowID, i, “qty”, qty, “//” + x + “//”, $(‘#jqxBOMGrid’).jqxGrid(‘getrowdata’, i));
    //$(‘#jqxBOMGrid’).jqxGrid(‘setcellvalue’, i, ‘QtyPreEdit’, j.Qty);
    //$(‘#jqxBOMGrid’).jqxGrid(‘setcellvalue’, i, ‘QtyPreEdit’, qty);
    //$(‘#jqxBOMGrid’).jqxGrid(‘setcellvalue’, i, ‘QtyPreEdit’, ‘steve’);
    //$(‘#jqxBOMGrid’).jqxGrid(‘setcellvaluebyid’, rowID, ‘QtyPreEdit’, ‘steve’);
    $(‘#jqxBOMGrid’).jqxGrid(‘setcellvaluebyid’, rowID, ‘QtyPreEdit’, qty);
    }
    }
    }

    The Grid defines QtyPreEdit as:
    { text: ‘QtyPreEdit’, datafield: ‘QtyPreEdit’, hidden: true, editable: true, sortable: false },

    In other code of this application I am able to set QtyPreEdit without error, in the same fashion as what is failing here.

    The initial value of QtyPreEdit = ”.
    The value of ‘qty’ being used to set QtyPreEdit is the string ‘1’. But you can see how even ‘steve’ fails.

    The error is:
    Uncaught TypeError: Cannot read property ‘displayfield’ of null
    at Object.<anonymous> (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:1594677)
    at Function.each (http://127.0.0.1:8000/BOM_Builder/static/js/jquery.js:2:2881)
    at b.(anonymous function).setcellvalue (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:1594644)
    at b.(anonymous function).setcellvaluebyid (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:1593978)
    at Object.a.jqx.invoke (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:815)
    at Object.a.jqx.jqxWidgetProxy (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:5735)
    at HTMLDivElement.<anonymous> (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:10222)
    at Function.each (http://127.0.0.1:8000/BOM_Builder/static/js/jquery.js:2:2881)
    at n.fn.init.each (http://127.0.0.1:8000/BOM_Builder/static/js/jquery.js:2:846)
    at n.fn.init.a.fn.(anonymous function) [as jqxGrid] (http://127.0.0.1:8000/BOM_Builder/static/js/jqwidgets/jqx-all.js:7:10194)
    (anonymous) @ jqx-all.js:7
    each @ jquery.js:2
    setcellvalue @ jqx-all.js:7
    setcellvaluebyid @ jqx-all.js:7
    a.jqx.invoke @ jqx-all.js:7
    a.jqx.jqxWidgetProxy @ jqx-all.js:7
    (anonymous) @ jqx-all.js:7
    each @ jquery.js:2
    each @ jquery.js:2
    a.fn.(anonymous function) @ jqx-all.js:7
    postSavedBOMDtlReturn @ default_index_jqxCmdButtons_docReady.js:326
    (anonymous) @ default_index_jqxCmdButtons_docReady.js:294
    i @ jquery.js:2
    fireWith @ jquery.js:2
    y @ jquery.js:4
    c @ jquery.js:4

    'setcellvalue' is a failure #91572

    stevesl
    Participant

    Does ‘getrowdatabyid’ return a reference/point directly into the data behind the row?
    Such that any update to the object return by ‘getrowdatabyid’ will be reflected in the row in realtime?
    If yes then why can’t we have a ‘getrow(s)data’ method to make life easier?

    'setcellvalue' is a failure #91589

    Hristo
    Participant

    Hello stevesl,

    It looks as a wrong dataField.
    When you delete a row, this will delete a row with particular ID, but in the same position can have a row.
    For example, delete first row (rows: [{id: 0, data: data}, {id: 1, data: data2}]) -> (rows: [{id: 1, data: data2}]).
    You should use var rowid = $('#jqxGrid').jqxGrid('getrowid', 0); to get the real id of the current first row.
    Another way to set cell value is by ID – setcellvaluebyid method of the Grid.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.