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
55
error calling SetCellValue after new row is created in the igGrid
posted

Hello -

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);

  • 840
    Offline posted
    Hello Andrew,
    After investigating this further, I determined that the exception is thrown because editCellEnded event is triggered when a row is being added to the grid. However, the id of the row is still not set and it is not yet available in the dataSource. What I could suggest is checking whether rowAdding is set to false via the ui argument of the event, if yes, the value would be changed:
    editCellEnded: function (evt, ui) {
           if (!ui.rowAdding) {
                 var rowID = ui.rowID;
                 var cellVal = $("#grid").igGrid("getCellValue", rowID, "ChangeValue");
                  if (cellVal) {
                       $("#grid").igGridUpdating("setCellValue", rowID, "ProductNumber", "new Product Number " + cellVal);
                    }
              }
      }
    Additionally, when a row is added, the cell value could be changed in a method bound to the rowAdding event as follows:
    rowAdding: function(evt, ui){
                                if(ui.values.ChangeValue){
                                    ui.values.ProductNumber = "new Product Number";
                                }
                            }
    Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,
    Monika Kirkova,
    Infragistics

    igGridChangeCellValue.zip