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,
If you have placed a HiddenField anywhere on the page, it will not be a descendant of the currentRow, unless you have used a TemplateDataField and placed the HiddenField inside the template. Please let me know if this is the case.
Otherwise you should be able to find the HiddenField as suggested above:
$("input[name$='hfChangeTo']")
If it does not work , please copy/paste the exact error you see.
Hristo, there is an error. How can I find HiddenField in a row that I was referring using currentrow.
If I try your suggested currentrow it gives error.
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
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:
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.