How can one update hiddenfield value as data in unbound column is added/edited?
I was trying to do it like below but it didnot work. It shows 'undefined', when I try to view the value using alert.
function cellValueChange(sender,args){
var currentrow=$(this).closest('tr');
if(args.get_cell(2).get_column().get_key() == "Amount"){
currentrow.find("input[name$=hfChangeTo]").val(args.get_cell(2).get_value());
alert(currentrow.find("input[name$=hfChangeTo]").val());
}
Hi Birendra,
I am not sure which var exactly returns undefined, but I will point what does not seem ok with this code and needs to be modified:
1) this in the context of this function should return the function, not an html element that can be wrapped as jQuery object:
You could either get the tr element as follows:
var currentRow = args.get_cell().get_row().get_element();
2) You use .find to get the input element, but .find travers only the descendants of the currentRow, while input is not there. You can get the input by its id or classname as follows:
$("input[name$='hfChangeTo']")
Applying the suggested should resolve your issue. Please let me know if you have further questions on the matter, I will be glad to help.
Thanks Hrristo it works. I had done it like below:
$("input[name$='hfChangeTo']").val(args.get_cell(2).get_value()); //Update hidden field with cell value