Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
error calling SetCellValue
posted

Hi,

I have a grid that allows for new rows to be inserted. I have logic in a client side JS event handle for editCellEnded that changes one of the cell values based on others. It works as expected for existing rows in the grid and successfully updates the cell. However, when I add a new row to the grid and edit one of the cells, I get an error when trying to update one of the cells using Javascript I can see the rowID is correctly set as well as the columnKey. Is there some restriction on doing this until the grid changes are persisted?

Javascript call in EditCellEnded handler that causes the issue.

//success - getting values out of the grid no problem - where Row id is variable holding the ID of the row

var N_Awarded = $("#Grid_101).igGrid("getCellValue", RowID, "N_Feasible");

//causes error

$("#Grid_101).igGridUpdating("setCellValue", RowID, "Cost_1", UpdatedCost);

Thanks in advance.

  • 1160
    Offline posted

    Hello Darryl,

    After investigating this further, I determined that the cell value could be changed in two ways.

    The first option is to get the id of the new row in a method bound to the rowAdding event and to use that id in the editCellEnded as follows:

    rowAdding: function (evt, ui) {

             rowID = ui.values.ID;

    },

    editCellEnded: function (evt, ui) {

             if (!ui.rowAdding) {

                    rowID = ui.rowID;

             }

             var N_Awarded = $("#grid").igGrid("getCellValue", rowID, "Maker");

             $("#grid").igGridUpdating("setCellValue", rowID, "Model", N_Awarded);

    },

    The other option is to change the cell value for the newly added row directly in the method bound to the rowAdding event and in the editCellEnded to change the value only if the row is already in the grid:

    rowAdding: function (evt, ui) {

                ui.values.Model = ui.values.Maker;

    },

    editCellEnded: function (evt, ui) {

                if (!ui.rowAdding) {

                     var N_Awarded = $("#grid").igGrid("getCellValue", ui.rowID, "Maker");

                     $("#grid").igGridUpdating("setCellValue", ui.rowID, "Model", N_Awarded);

                }

    },

    Below I am attaching a sample, demonstrating the described behaviors. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,
    Monika Kirkova,
    Infragistics

    igGridSetCellValue.zip

  • 15
    Offline posted