jQWidgets Forums
jQuery UI Widgets › Forums › Grid › cells resetting instead of accepting input
This topic contains 3 replies, has 2 voices, and was last updated by ivailo 8 years, 6 months ago.
-
Author
-
I have a fairly simple editable grid with an add rows button. When the user adds data to a cell and clicks the add row button while the cursor is still in that cell (the data has not been finalized and submitted to the cell), the data they’ve input is removed instead of being accepted.
I’ve been able to get around this with a simple event trigger like this:
$(“#mygrid”).on(‘cellendedit’, function (event)
{
var args= event.args;
if (args.value == args.oldvalue) {
$(“#mygrid”).jqxGrid(‘setcellvalue’, args.rowindex, args.datafield, args.value);
}
});That works surprisingly well.
Now, I’ve got a second grid that is slightly more complicated. This grid has a column of checkboxes. Usually when a user is editing a cell and clicks on another cell, their input is finalized and there’s no need for my event. This doesn’t happen when the click the checkbox and my event hack doesn’t work here because the cell being edited actually stays in edit mode. It simply loses the data being input.Any ideas for how I might work around this?
Hi bach,
In your case you can use selectionmode: ‘checkbox’ instead checkbox column and bind to the rowselect event.
Here is a demo with checkbox selection mode.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comApologies, I think my initial post was unclear. I’m not using the checkbox as a selection mode. I’m actually using it to trigger some css changes, but that’s not too important.
I’ve put together a fiddle to show the issue. In the process of putting this together, I found the actual cause of my troubles and it appears to be a bug.http://jsfiddle.net/z9br38f0/43/
Try changing the text in one of the Last Name column cells. While that cell still has focus, click on one of the other cells. Focus is moved to the new cell, and the text in the first cell is accepted. Now try the same thing, but instead of clicking on another text cell just click the checkbox in that row. Now focus is not moved from the first cell but the text changes are lost.
Next, comment out line 109, (autoheight: true) or change it to false. Try the same thing with the checkbox and this time you’ll see that, although focus is not shifted from the cell being edited, the text changes are not lost. This seems to be the correct interaction, and what I’d like to achieve.
Therefore, it seems that there is a bug with autoheight which, unfortunately, I need to use on my grids.
Anything that can be done to fix this?
Let me know if the example fiddle is not clear enough.Thank you
Hi bach,
You can try to use an approach with
editmode: 'selectedrow'
.
In the following demo, your changes are not lost when the checkbox is checked/unchecked.
http://jsfiddle.net/pg20jx5b/Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.