2013-01-21 44 views
0

通我有一个Grails与此 选定的jqGrid行按钮与动作

<script type="text/javascript"> 
    /* when the page has finished loading.. execute the follow */ 
    $(document).ready(function() { 
     jQuery("#customer_list").jqGrid({ 
      url:'jq_customer_list', 
      datatype: "json", 
      colNames:['customer','location','id'], 
      colModel:[ 
      {name:'customer'}, 
      {name:'location',stype:'select', searchoptions:{value:':All;USA:USA;Canada:Canada;Carribean:Carribean;USPacific:USPacific;'}}, 
      {name:'id', hidden:true} 
      ], 
      rowNum:2, 
      rowList:[1,2,3,4], 
      pager: jQuery('#customer_list_pager'), 
      viewrecords: true, 
      gridview: true, 
      multiselect: true 
     }); 
     $("#customer_list").jqGrid('filterToolbar',{autosearch:true}); 
    }); 
    </script> 
<g:link controller="MyController" action="downloadFile">Download</g:link><br> 
    </div> 
<br/><br/> 

查看现在我想从所选行进入该操作中的数据。但是,我无法在任何地方找到它。

我的控制器上的方法目前是空白的。我只想打印到控制台所有选定值的ID。

有什么建议吗?谢谢

+0

创建一个隐藏的输入来存储值。无论输入的名称是什么,都是您在控制器中引用它的内容。 'params.name' –

+0

这个相关的文章应该让你去[jqGrid:传递选定的ID作为HTML表单参数](http://stackoverflow.com/questions/7836192/jqgrid-pass-selected-ids-as-html-form -parameters) – uchamp

回答

1

这应该做到这一点。

onSelectRow: function(rowid, iRow, iCol, e){ 
    console.log('Id of Selected Row: ' + $(this).jqGrid('getCell', rowid, 'id')); 
} 
+0

我该如何将它传递给g:link action? – Badmiral

+0

对grails不熟悉,你想要做什么?所有这一切都告诉jqGrid,当选中一行从提取的行中提取一些数据,并将其显示到控制台。应该没有理由不能把它传递给别的东西。 – Mark

+0

我想通过这个后置动作来下载一个包含所有数据的文件 – Badmiral