如何使用表单 post 导出选定数据
How to export selected data with form post
我正在尝试将所选数据从我的 ui-grid 导出到我正在构建的另一个 Web 应用程序uilding,该应用程序通过表单 post 接受数据。所以,我添加了一个带有功能的自定义菜单项...
gridMenuCustomItems: [
{
title: 'Export to Texter',
action: function($event) {
console.log($scope.gridApi);
alert('do the export here');
},
order: 210
}
],
到目前为止这有效,但是有人可以告诉我如何获取选定的行,然后通过表单 post 导出一列(在我的例子中是 RegID)的所有值吗?
我有一些工作。我确定有人可以改进它(我不得不求助于 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
}
],
我正在尝试将所选数据从我的 ui-grid 导出到我正在构建的另一个 Web 应用程序uilding,该应用程序通过表单 post 接受数据。所以,我添加了一个带有功能的自定义菜单项...
gridMenuCustomItems: [
{
title: 'Export to Texter',
action: function($event) {
console.log($scope.gridApi);
alert('do the export here');
},
order: 210
}
],
到目前为止这有效,但是有人可以告诉我如何获取选定的行,然后通过表单 post 导出一列(在我的例子中是 RegID)的所有值吗?
我有一些工作。我确定有人可以改进它(我不得不求助于 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
}
],