views:

221

answers:

1

Using jqGrid I want to generate delete links for each row in the grid. The standard way to do this is to add the links in the gridComplete callback like shown below:

gridComplete: function() {                                                                                                                                      
  var ids = jQuery("#jobs_table").jqGrid('getDataIDs');                                                                                                         
  for(var i=0;i < ids.length;i++){                                                                                                                              
    var cl = ids[i];                                                                                                                                            
    be = '<%= link_to(image_tag("delete.gif", :border=>0, :size=>"20x22", :alt => "delete"),⋅                                                                   
              { :action => 'destroy', :id => 'cl', :method => :delete}, :class => 'ajax')  -%>';                                                        
    jQuery("#jobs_table").jqGrid('setRowData',ids[i],{workflow_state:be});                                                                                      
  }                                                                                                                                                             
},                                                                                                                                                              

Using getDataIDs I get a list of IDs that I can use to generate the delete links. The problem is that this is a javascript call that results in a javascript variable.

The question is how can I use this variable "cl" inside rails link_to view helper?

A: 

Are you just wanting to add a delete button to each row? If so why dont you just return a column called delete then add custom formatter in your javascript that returns the button.

Custom Formater

David
That is what I am doing but instead of a formatter I simply add the link html code in the created_at column.
Horacio