jQuery UI Widgets › Forums › Grid › Change value after user has entered
Tagged: case, Cell, cellendedit, cellvaluechanging, createeditor, edit, geteditorvalue, grid, jqxgrid, toUpperCase, upper, uppercase, value
This topic contains 5 replies, has 3 voices, and was last updated by Sameer Ahmed 7 years, 6 months ago.
-
Author
-
Two questions:
Want to invoke the following user experience. When they edit a particular value, the value in the grid is automatically changed to uppercase. I’ve tried setting the value of the cell, but everything I’ve tried does not seem to effect the changed value.
Different case, upon value changing, change column values in other rows so a sequence can be maintained. Ie, there exists a 1, 2 & 3. Someone edits 3 and changes to 2. Want to find existing 2 and increment to 3, thus no row has the same value. I would think this is best done in the endcelledit event. If executed in cellvaluechanged, would this create an infinite loop?
Thanks
Hello Zylin,
1) To achieve this, please use the cellvaluechanging callback function:
cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) { return newvalue.toUpperCase();}
2) Here is what your cellendedit function may look like:
cellendedit: function (row, datafield, columntype, oldvalue, newvalue) { var rows = $('#jqxgrid').jqxGrid('getrows'); for (var i = 0; i < rows.length; i++) { var currentValue = $('#jqxgrid').jqxGrid('getcellvalue', i, "Quantity"); if (currentValue == newvalue) { $("#jqxgrid").jqxGrid('setcellvalue', i, "Quantity", newvalue + 1); break; }; };}
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dimitar,
Many Thanks. Tried the return on cellendedit and on cellvaluechanged, but didn’t know about cellvaluechanging.
Regards,
SteveHi Ditimar,
cellvaluechanging is called from endcelledit but i need to change the value to upper case while user is typing. How could we achive that.
Thank you.Hi Sameer Ahmed,
Here is how you can achieve this requirement: https://www.jseditor.io/?key=jqxgrid-uppercase-editor. Note the implementations of createeditor and geteditorvalue for the first column.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
Thank you for the response. It worked. -
AuthorPosts
You must be logged in to reply to this topic.