Set grid cell value

QuestionsSet grid cell value
Misic Dragan asked 11 years ago

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

6 Answers
Abu Ghufran answered 11 years ago

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>

Misic Dragan answered 11 years ago

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

Misic Dragan answered 11 years ago

It is not working only in inline editing. When I using separate form editing it is OK.

Abu Ghufran answered 11 years ago

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

Andy answered 11 years ago

how to work this example in inline editing?? any solution?
thanks!

Your Answer

16 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?