jQuery UI Widgets Forums Grid change cell values on combobox value changing

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

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

  • brasio
    Participant

    Hi all, I’m testing jqxgrid but I’m experiencing this issue. I would like to change the column2 cell value (based on some logic which is not important to say) when I change a combobox in column1. I don’t even understand if the following approach is correct:

    …….
    columns: [
    { text: ‘column1’,datafield: ‘mydatafield’, displayfield: ‘mydisplayfield’, columntype: ‘combobox’,
    createeditor: function (row, value, editor) {
    editor.jqxComboBox({ source: myAdapter, displayMember: ‘field1’, valueMember: ‘field2’ });
    editor.on(‘change’, function () {
    var el = editor.jqxComboBox(‘getSelectedItem’);
    if (editor.jqxComboBox(‘selectedIndex’) != -1) $(“#jqxgrid”).jqxGrid(‘setcellvalue’, row, “column2”, “myvalue”);
    else $(“#jqxgrid”).jqxGrid(‘setcellvalue’, row, “column2”, el.label);
    });
    }
    },
    { text: ‘column2’ ………………

    The issue is that if I change column1 combobox value for example in row number 1 and then I do the same for row number 2, not only column2 value of row number 2 are changed, but also column2 value of row number 1: it seems that row parameter in ‘createeditor: function (row’ remains in memory.
    The same happens if I use initeditor instead of createeditor event.

    Which is the correct approach?

    Please note that cascading combobox example is not suitable for me, as it works while editing the second column (City column).

    Thanks


    Dimitar
    Participant

    Hi brasio,

    Setting a cell value while another cell is in edit mode is not recommended. We suggest you call setcellvalue for the second cell on the cellendedit event of the first cell.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    brasio
    Participant

    Hi DImitar, thanks for your reply. I wrote as suggested:

    $("#jqxgrid").on('cellendedit', function (event)
    {
     if(event.args.datafield == 'mydatafield')
     {
      var column = $("#jqxgrid").jqxGrid('getcolumn', event.args.datafield);
      var row = event.args.rowindex;
      $("#jqxgrid").jqxGrid('setcellvalue', row, "mydatafield2", "myvalue");
     }
    });

    but now there is another problem: when i setcellvalue on cellendedit event, grid update method is invoked, resulting in several calls, one invoked by cellendedit event and another one for the ‘setcellvalue command’.


    Dimitar
    Participant

    Hi brasio,

    This is a normal behaviour – updaterow is called every time a cell has been edited (either manually or programmatically).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.