Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1230
Update HiddenField on Unbound column cell changed
posted

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());

}

}

Parents
No Data
Reply
  • 16310
    Verified Answer
    Offline posted

    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:

    var currentrow=$(this).closest('tr');

    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.

Children