jQuery UI Widgets › Forums › Grid › is there a way to dectect the current cell?
Tagged: Cell, cellbeginedit, detection, edit, Edit Mode, edited cell, endcelledit, grid, jqxgrid
This topic contains 2 replies, has 2 voices, and was last updated by Dundee 9 years, 10 months ago.
-
Author
-
I want to know if there any method to find the current cell in the grid where the user cursor is and where is currently editing content ?
Problem:
I have a grid with 4 columns and a button that allow me to add row. Everytime i click on the button and the focus/cursor are still in one cell, the content in those cell are removed. The cell need to loose the focus before to keep th content intact.All i want to do is to detect in which cell the user is editing when the “Add row” button is hited, so i can use the “endcelledit” event to tell to the current cell to loose focus and after i could add row without any problem.
Here the add button part code :
addButton.click(function (event) { var rowId = $('#candidatesListDisplay').jqxGrid('getselectedrowindex'); $("#candidatesListDisplay").jqxGrid('endcelledit', rowId,"office", false); $("#candidatesListDisplay").jqxGrid('addrow', null, {}); });
In this example you can see i found the rowId and call the “endcelledit” event with “office” as column name. But if the user was in other column than “office” that cause error. I would like to detect the column so i can do a switch or if section and call “endcelledit” only for the current cell.
I hope this is clear the way i explain it…abnd thank for you help
Hello Dundee,
Our suggestion is to create a flag variable, e.g. editedColumn, which to set in the cellbeginedit event handler each time a cell enters edit mode, i.e.:
$("#jqxGrid").on('cellbeginedit', function (event) { // event arguments. var args = event.args; // column data field. var dataField = event.args.datafield; editedColumn = dataField; });
This way, when you click addButton, you will also have access to the cell’s column.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/a great thank to you….it’s was so simple after reading you…
have a nice day
-
AuthorPosts
You must be logged in to reply to this topic.