Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate the element clicked on to the selection_handler #11

Open
charl opened this issue Feb 12, 2010 · 0 comments
Open

Propagate the element clicked on to the selection_handler #11

charl opened this issue Feb 12, 2010 · 0 comments

Comments

@charl
Copy link

charl commented Feb 12, 2010

I have a jqGrid with a subgrid where I need to determine which element in the master grid was clicked on to cause the subgrid to be displayed. This is required when items in my subgrid are not unique so they (and their ids) can repeat for one or more elements in the master grid.

It would be very useful if one was able to pass the element which was clicked on to the grid as a second parameter to the selection_handler so that you're able to find which line was clicked on in the master grid that caused the elements in the subgrid to be displayed.

I guess this could be an option which is passed into jqgrid().

Here's a unified diff between my suggestion and the latest plugin installed via '/script/plugin install git://github.com/ahe/2dc_jqgrid.git' on 22 Jan 2010:

$ diff -u vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb.new
--- vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb 2010-02-12 16:17:55.000000000 +1100
+++ vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb.new 2010-02-12 16:07:48.000000000 +1100
@@ -193,7 +193,7 @@
subgrid_direct_link = %Q/
onSelectRow: function(id){
if(id){

  •          #{options[:subgrid][:selection_handler]}(id); 
    
  •          #{options[:subgrid][:selection_handler]}(id, this); 
         } 
       },
       /
    

In your javascript selection_handler you can do something like this:

jqgrid_click = function(id, element) {
alert('You clicked on ' + $('#' + element.id));
}

The ActiveRecord id for the element clicked in the master grid will be encoded in element.id which you can simply extract with a little string manipulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant