JS Event handler row selected

QuestionsJS Event handler row selected
Carlos asked 11 years ago

Hello everybody,

I would like to know how to add JS Event handler to my datagrid on rowSelected.

So I can perform other actions based on the selected row / ID

18 Answers
varun answered 11 years ago

jQuery('#list1').jqGrid('getGridParam','selrow');

Abu Ghufran answered 11 years ago

Refer demos/editing/custom-events.

$e["js_on_select_row"] = "do_onselect";
$grid->set_events($e);

and in html part …

<script>
function do_onselect(id)
{
alert('Simulating, on select row event')
var rd = jQuery('#list1').jqGrid('getCell', id, 'company'); // where invdate is column name
jQuery("#span_extra").html(rd);
}
</script>

Cristian Engelmann answered 10 years ago

Hi,

The same example.
But, I want to 'campany' field into my subgrid.
how can I do it?

Thank a lot of.

Abu Ghufran answered 10 years ago

Hello,

In master grid, you need to define:

// comma sep. fields. will be POSTED from parent grid to subgrid, can be fetching using $_POST in subgrid
$opt["subgridparams"] = "company";
$grid->set_options($opt);

And in detail grid page, you can read it with:

$comp = $_REQUEST["company"];

Cristian Engelmann answered 10 years ago

Sorry I tray to explain again.The same
Refer demos/editing/custom-events.

$e["js_on_select_row"] = "do_onselect";
$grid->set_events($e);

and in html part …

<script>
function do_onselect(id)
{
alert('Simulating, on select row event')
var rd = jQuery('#list1').jqGrid('getCell', id, 'company'); // where invdate is column name
jQuery("#span_extra").html(rd);
}
</script>

but I want to
<script>
function do_onselect(id)
{
alert('Simulating, on select row event')
var rd = jQuery('#list1').jqGrid('getCell', id, 'company'); // where invdate is column name
jQuery("#span_extra").html(rd);

when I do to click in the sub grid, I want to information the 'campany2'

var rd = jQuery('#subgri1').jqGrid('getCell', id, 'company2'); // where invdate is column name
jQuery("#span_extra").html(rd);

}
</script>

Abu Ghufran answered 10 years ago

Instead of #subgrid1 use #<?php echo $g->id?>

function do_onselect(id)
{
alert('Simulating, on select row event')
var rd = jQuery('#<?php echo $g->id?>').jqGrid('getCell', id, 'company2');
jQuery("#span_extra").html(rd);
}
</script>

Cristian Engelmann answered 10 years ago

Does not work!
When I use alert(rd) the answer is "false" and I use alert(id) the answer is rowid information, it is ok.

Abu Ghufran answered 10 years ago

I've emailed you lib update. Please update.
Also confirm by alerting

alert('<?php echo $g->id?>');

and make sure company2 is your column name of subgrid.

Cristian Engelmann answered 10 years ago

alert('<?php echo $g->id?>');

it show blank, nothing.

I have to phpgrid-full-v1.4.8.2
Is it necessary the new version?

thank you, again.

Abu Ghufran answered 10 years ago

Yes, it is added in newer version.
Just override the emailed file jqgrid_dist.php in lib/inc.

Cristian Engelmann answered 10 years ago

does not work!

function do_onselectAcceSub(id)
{
alert('Simulating, on select row event')
var rd = jQuery('#<?php echo $g->id?>').jqGrid('getCell', id, 'codigo_familiaE');
jQuery("#span_extra").html(rd);
alert('<?php echo $g->id?>');
alert('rowid '+id);
}

This alert('<?php echo $g->id?>'); show blank, nothing.
This alert('rowid '+id); show the information that is the same 'codigo_familiaE'

I install to jqgrid_dist.php new over old on /lib/inc/

thank yuo again.

Abu Ghufran answered 10 years ago

Your object var name is $grid, so replace $g with $grid.

Cristian Engelmann answered 10 years ago

I use bouth in
"var rd = jQuery('#<?php echo $g->id?>').jqGrid('getCell', id, 'codigo_familiaE');"

and
"var rd = jQuery('#<?php echo $grid->id?>').jqGrid('getCell', id, 'codigo_familiaE');"

the result is same, blank.
but, This alert('rowid '+id); show the information that is the same 'codigo_familiaE'

Thank you

Abu Ghufran answered 10 years ago

Please share complete code for review.
You can share using pastebin.com

Abu Ghufran answered 10 years ago

Enelmann, please ignore last message. Found your email with code.
Will be updating you back on email.

Cristian Engelmann answered 10 years ago

To day in the morning, I send you a e-mail with 2 example.
please answer me.

Thank you again

Cristian Engelmann answered 10 years ago

sorry I send to e-mail again.

Thank you

Abu Ghufran answered 10 years ago

I've emailed you working demos videos and files.

Your Answer

12 + 15 =

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?