Hi all,
How I can programmatically change value in grid cell? I have onblur event which need populate some row cell based on value entered in first cell.
Regards
Here is the sample from FAQ.
##### Q) How to populate other column, based on previous columns?
In following example, text3 will be calculated based on text1 & text2. You can use onblur event and do your own JS code to set value. You can also inspect the ID of elements of form using firebug.
$col = array();
$col["title"] = "Height";
$col["name"] = "height";
$col["editable"] = true;
$col["editoptions"] = array("onblur" => "update_field()");
$cols[] = $col;
$col = array();
$col["title"] = "Width";
$col["name"] = "width";
$col["editable"] = true;
$col["editoptions"] = array("onblur" => "update_field()");
$cols[] = $col;
$col = array();
$col["title"] = "Area";
$col["name"] = "area";
$col["editable"] = true;
$cols[] = $col;
and in html, put following js function to calculate field.
<script>
function update_area()
{
jQuery('#area:visible').val( parseInt(jQuery('#width:visible').val()) * parseInt(jQuery('#height:visible').val()))
}
</script>
I tried that. This is my code.
//php code
$col = array();
$col["title"] = "Part Number";
$col["name"] = "Display_Number";
$col["width"] = "105";
$col["editable"] = true;
col["editoptions"] = array("onblur" => "partNumberBlur()");
// java script code
function partNumberBlur(){
var rr = jQuery('#Display_Number').val();
alert(rr);
}
partNumberBlur is called when I leave Display_Number field, but rr is undefined.
Where I went wrong.
Regards
It is not working only in inline editing. When I using separate form editing it is OK.
Hello,
I would suggest to use input[name=field] selector instead of ID (#field). For e.g.
jQuery('input[name="cost"]:visible').val( parseFloat(jQuery('input[name="base_price"]:visible').val()) * 1.1);