Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.14.0 getCell gives undefind-alert in beforeEditCell, editmode if cellname same as editcell #328

Closed
PeterSandberg opened this issue May 5, 2017 · 6 comments

Comments

@PeterSandberg
Copy link

Hello!
After upgrade to 4.14.0 i get an alertbox says 'undefined' when...

`
beforeEditCell: function (rowid, cellname, value, irow, icol) {

//Occurs here if 'cellname' is the same as the current cell in editmode)
var value = $grid.getCell(rowid, 'QTY'))

},
cellEdit: true,
`
Also occurs in afterSaveCell etc.
Can prevent it by adding code in the events. But wonder if it's a bug or it is by design?

Best regards
Peter Sandberg

@OlegKi
Copy link
Member

OlegKi commented May 7, 2017

Hi Peter!

Please, send the demo, which can be used to reproduce the problem, or at least more detailed JavaScript code (where the column QTY is defined). I suppose that you could have the same problem, which is fixed in the commit (see the issue for details). Thus please test your demo with the latest code from GitHub: you need just load free jqGrid files from https://rawgit.com/free-jqgrid/jqGrid/master/css/ui.jqgrid.css and https://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js. If the bug still exist then I need be able to reproduce the code and to debug it. Thus I need to have the demo and the test case (step by step instruction, which can be used to reproduce the problem).

Regards
Oleg

@OlegKi
Copy link
Member

OlegKi commented May 11, 2017

Do you tested whether the described problem exist with the latest sources of free jqGrid (see my previous post)? Please send me additional information or close the issue if the described problem is not exist more.

@PeterSandberg
Copy link
Author

I am testing right now (sorry am late) ! Will return later tonight with the result!!

@PeterSandberg
Copy link
Author

PeterSandberg commented May 11, 2017

Can't get: var qty = $grid.getCell(rowid, 'QTY');
to work in: beforeEditCell: function(rowid, cellname, value, irow, icol)

See: https://jsfiddle.net/2x8oddqx/71/

OlegKi added a commit that referenced this issue May 11, 2017
Thanks @PeterSandberg (https:/PeterSandberg) for reporting the problem. See #328 for more details.
@OlegKi
Copy link
Member

OlegKi commented May 11, 2017

Thanks for the demo. I posted the small changes, which fixes the problem.

Nevertheless I'd recommend you don't use getCell or getRowData in case of using datatype: "local". The method getLocalRow works much more effective:

var qty = $(this).jqGrid("getLocalRow", rowid).QTY;

Even if your real application uses datatype: "json" without loadonce: true, the code

var qty = 'QTY' === cellname ? value: $(this).jqGrid("getCell", rowid, 'QTY');

or

var p = $(this).jqGrid("getGridParam");
var qty = p.colModel[icol].name === cellname ? value: $(this).jqGrid("getCell", rowid, 'QTY');

will be better as your original code. The above code works with 4.14.0. See https://jsfiddle.net/OlegKi/2x8oddqx/72/

@PeterSandberg
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants