2016-04-25 18 views
0

我試圖將所選數據從我的ui-grid導出到另一個正在構建的通過表單發佈接受數據的web應用程序。所以,我添加了一個功能的自定義菜單項...如何使用表單發佈所選數據

 gridMenuCustomItems: [ 
     { 
      title: 'Export to Texter', 
      action: function($event) { 
      console.log($scope.gridApi); 
      alert('do the export here'); 
      }, 
      order: 210 
     } 
     ], 

到目前爲止是這種情況,但有人可以點我如何獲得所選行的方向,然後導出的所有值一列(RegID,在我的情況下)通過表格帖子?

這裏是我的plunker:https://plnkr.co/edit/qsWac1FtIiblBKL3qALM?p=preview

回答

0

我已經得到的東西的工作。我確定有人可以改進它(我不得不求助於表單提交的jQuery,因爲我熟悉它並且可用),但這對我來說很有用。

我應該注意到,我需要整個頁面重定向到新的應用程序,所以AJAX處理是不夠的。

 gridMenuCustomItems: [ 
     { 
      title: 'Export selected to Some App', 
      action: function($event) { 
      var currentSelection = $scope.gridApi.selection.getSelectedRows(); 
      var currentSelectionUserIds = []; 
      currentSelection.forEach(function(entry) { 
       currentSelectionUserIds.push(entry.userId); 
      }); 
      $myExportForm = $('<form id="ExportForm" action="/Link/To/My/App/" method="post"><input type="hidden" name="UserIDs" value="' + currentSelectionUserIds + '"></form>'); 
      $('body').append($myExportForm); 
      $myExportForm.submit(); 
      }, 
      order: 210 
     } 
     ],