Hi there, I've updated my project from IgniteUI 14.1 to 16.1, and JQuery from 1.7.2 to 1.9.1.
In my grid, on the second level, I use the "iggridupdatingeditcellstarted " event to check if the new value is negative, and handle that, as such:
// Get current Row
var row = ui.owner.grid.dataSource.dataView()[ui.owner._rowIndex];
// Calculate new balance
var balance = row.transfer_size_qty - ui.value
// If it will go negative, set to intransit_size_qty
if (balance < 0)
{ ui.value = row.intransit_size_qty; }
In 14.1, this code worked but since updating to 16.1 I get "JavaScript runtime error: Unable to get property 'transfer_size_qty' of undefined or null reference"
In Intellisense, I get "row.intransit_size_qty", but not "row.transfer_size_qty" coming up, yet they both seem to be correctly defined in the grid and the model.
If I add: alert(row.transfer_size_qty) after " var row = ..." its then recognized, but if I remove it, its gone again.
Any ideas what could be causing this?
Thanks Deon
Hello Deon,
Thank you for contacting Infragistics!
I have done looking into this matter and it seem like ui.owner._rowIndex does not exist anymore so you are unable to use it. Note it is not recommend to use internal methods/members (marked by a leading “_”) as they could possibly change between versions. Instead you would want to use the public methods/members. To get the cell value for comparing/using I would instead recommend using the getCellValue method:
var cellValue = $("#grid1").igGrid("getCellValue", ui.rowID, “ProductQty”);
http://www.igniteui.com/help/api/2016.1/ui.iggrid#methods:getCellValue
Hi Mike,
Thanks for your response. This did resolve the original error.
However, I am now getting the error as described in this link: https://es.infragistics.com/community/forums/f/ignite-ui-for-javascript/87874/cannot-update-a-cell-after-while-updating-other-cell---editing-grid.
Calling the statement you provides causes that error, and the grid no longer responds - I cannot collapse/expand rows, or click in any more cells. if I remove that line of code, the grid behaves as it should.
Any ideas on how to resolve this?
Regards
Deon
I am loading ithe scripts at the tope of the view like this:
@(Html.Infragistics().Loader()
.ScriptPath(Url.Content("~/Infragistics/js/"))
.CssPath(Url.Content("~/Infragistics/css/"))
.Theme("infragistics2012")
.Render()
)
My functions in the scripts section are:
$("#grdReceipts").bind("iggridupdatingeditcellstarted", function (event, ui) {
if (!ui.editor) {
return;
}
if (ui.columnKey === 'ct_size_scale_desc') {
ui.editor.igEditor('option', 'readOnly', true);
$("#saveChanges").igButton("disable");
$('#saveChanges').val('Not Ready');
//var row = ui.owner.grid.dataSource.dataView()[ui.owner._rowIndex];
var text = ui.owner.grid.getCellValue(ui.rowID, "grv_qty");
if (text === null) {
ui.owner.updateRow(ui.rowID, { 'grv_qty': ui.owner.grid.getCellValue(ui.rowID, "intransit_size_qty") });
// ui.owner.setCellValue(ui.rowID, "grv_qty", row.intransit_size_qty);
// ui.owner._notifyChanged();
});
$("#grdReceipts").bind("iggridupdatingeditcellending", function (event, ui) {
var balance = ui.owner.grid.getCellValue(ui.rowID, "transfer_size_qty") - ui.value
if (balance < 0) {
ui.value = ui.owner.grid.getCellValue(ui.rowID, "intransit_size_qty");
if (ui.value < 0) {
ui.value = 0;
$("#saveChanges").igButton("option", "disabled", false);
$('#saveChanges').val('Save Changes');
var parentTR = ui.owner.grid.element.closest("tr").prev();
var parentRowId = $(parentTR).attr('data-id');
var text = $("#grdReceipts").igGrid("getCellValue", parentRowId, "intransit_qty");
$("#grdReceipts").igGridUpdating("setCellValue", parentRowId, "intransit_qty", text, parentTR);
This is all local i.e. I am debugging, and my DB is on my machine. There do not appear to be any other errors other than the similar error as describe in the link:Uncaught Error: cannot call methods on igEditorFilter prior to initialization; attempted to call method 'SetFocus'
Thank you for the update. I have created a sample and I have been unable to reproduce this behavior. It works for me without issue. I am attaching my sample, note that I have removed the Infragistics JavaScript and CSS files due to file size limitations of attaching to the forums. Please run my sample and let me know what behavior you see. Also please send me an isolated sample that reproduces the issue for you so I can look further into this matter and see what may be causing this behavior for you.
Hey Mike,
Thanks for the sample, I have amended it with the functionality I am trying to implement, and it also does not work here. I am new to MVC so perhaps I am just doing something wrong. Please find attached my amended sample.
You'll see that I have added a column called "MyTestValue" to the Category level. When clicking in the cell, I would like to set the value to the CategoryID if it is empty. I added the grid function" iggridupdatingeditcellstarted" to the Scripts section, and tried to do that.
Without that function, I am able to click in to the next row, but with I am not able to - this is the error I now get: 0x800a138f - JavaScript runtime error: Unable to get property 'options' of undefined or null reference
Please note this is not the same as my original error, but it overall it behaves the same way.
Basically, I am trying to default a cell's value to another one in the row if it is empty (in the iggridupdatingeditcellstarted event), and not allow the value to exceed the other cell's value (in the iggridupdatingeditcellended event).
Any assistance in getting this to work will be appreciated.
Thanks
Thank you for the update. For both the behaviors you want to achieve you will want to check the column key before you run any operations, otherwise you will be performing them for every cell, which is part of the issues you are having. I have reworked the code to demonstrate how you can achieve these behaviors. Note that in the cell edit ending you are using ui.owner.grid which the “grid” part doesn’t exist.
Thanks Mike. I am able to see what you have done, and it works on this level in the grid (Category)
My problem now is that I am actually trying to implement this on the 2nd level of my grid, (Product's level in this example) and it does not seem to work. Is there a different syntax for this?
Please see my attached example where I tried to implement this, I moved the MyTestValue column to the second (Product) level and tried to do the same but no luck.
Thanks Mike, have managed to get it working now.
I have modified the sample to be more generic so it works on both levels. Before when I said the edit ending didn’t have ui.owner.grid I was mistaken I was thrown off by you checking for “ID” when the column key should have been “ProductID” or “CategoryID”.