jQuery UI Widgets Forums Grid Problem with CreateEditor of Grid Column

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

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

  • Syai
    Participant

    Hi,
    When I’m working on Grid with inline functionality I found an issue with CreateEditor of “jqxComboBox” column. Below is the scenario I’m facing problem with.

    1) We are getting all the items to the Combobox.
    2) When I select the value in the Combobox, I’m getting the row number and with the row number I’m getting all the data of row and then making some calculations on other columns and updating.
    3) Here when I select another Item in another row of grid, the row number remained as “Previous selected row number” and the calculations done for the row data we are getting depending on the row number.
    4) This happened only when we are binding the combobox in “CreateEditor”. I changed it to “InitEditor” and did the same operations. It worked fine as it is getting the proper row number.
    —Is this the limitation of JQX Grid or did I miss anything to get this functionality.
    Below is the piece of code I’m using.

    createeditor: function (row, cellvalue, editor) {
    editor.jqxComboBox({ displayMember: 'TaxName', valueMember: 'TaxCodeId', source: taxCodeDataAdapter, checkboxes: false, dropDownWidth: 200 });
    //Get all the items
    var items = editor.jqxComboBox('getItems');
    $.each(items, function () {
    var item = this; item.title = item.label;
    });
    //Bind Select event for the combobox.
    editor.bind('select', function (event) {
    //GET THE SELECTED INDEX.
    selTaxCodeIndex = editor.jqxComboBox('getSelectedIndex');
    //GET THE GUID OF THE SELECTED TAX.
    if (editor.jqxComboBox('getSelectedItem') != null && selTaxCodeIndex != -1) {
    selTaxCodeId = editor.jqxComboBox('getSelectedItem').value;
    selTaxPercentage = editor.jqxComboBox('getSelectedItem').originalItem.TaxPercentage;
    }
    //Calculation of Amounts
    //Get the Row number and get RowData and perform calculations.
    var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', row);
    _vNetAmount = parseFloat(dataRecord.NetAmount);
    _vGrossAmount = _vNetAmount + (_vNetAmount * parseFloat(selTaxPercentage)) / 100;
    });
    }

    The above code worked by replacing createeditor with initeditor.

    Regards,
    Syai,
    Osmosys


    Peter Stoev
    Keymaster

    Hi,

    The “createeditor” should be used for the initialization of the editor – setting data source, displayMember, valueMember. That function is called just once when the editor is created.
    The “initeditor” as it is called each time should be used for synchronization of the ComboBox’s selectedIndex and the cell’s value.

    Best Regards,
    Peter Stoev

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


    Syai
    Participant

    Hi Peter,
    Thanks for the quick response. Is this the process we need to follow for this kind of scenarios or there any better way to achieve it?

    Regards,
    Syai,
    Osmosys

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

You must be logged in to reply to this topic.