Grid 从Shield UI网格导出所有记录
我正在尝试从数据网格导出所有数据。shield UI示例演示确实导出了所有记录,所以我知道这是可以做到的!当我这样做时,它只导出当前页面数据 Java代码片段:Grid 从Shield UI网格导出所有记录,grid,export,shieldui,Grid,Export,Shieldui,我正在尝试从数据网格导出所有数据。shield UI示例演示确实导出了所有记录,所以我知道这是可以做到的!当我这样做时,它只导出当前页面数据 Java代码片段: remote: { read: { type: "POST", url: "/portals/ajax" } } }); $("#manageportalsgrid").
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
$("#manageportalsgrid").shieldGrid({
dataSource: portals,
sorting: {
multiple: true
},
selection: {
type: "row",
multiple: true,
toggle: false
},
filtering: {
enabled: true
},
paging: true,
columns: [
{ field: "portalID", width: "130px", title: "Portal ID" },
{ field: "overx", width: "130px", title: "Overworld X" },
{ field: "overy", width: "130px", title: "Overworld Y" },
{ field: "overz", width: "130px", title: "Overworld Z" },
{ field: "netherx", width: "130px", title: "Nether X" },
{ field: "nethery", width: "130px", title: "Nether Y" },
{ field: "netherz", width: "130px", title: "Nether Z" },
{ field: "portalowner", width: "130px", title: "Portal Owner"},
{ field: "description", width: "130px", title: 'Portal Description'},
{
field:"actions",
width: "200px",
title:"Actions",
columnTemplate: $("#portalEditTemplate").html() + $("#portalDeleteTemplate").html()
}
],
toolbar: [
{
buttons: [
{
commandName: "csv",
caption: '<span class="sui-sprite sui-grid-icon-export-csv"></span> <span class="sui-grid-button-text">Export to CSV</span>'
}
]
}
],
exportOptions: {
proxy: "/attachments/save",
csv: {
fileName: "Viikis Community Server portals " + getMonthforFile(),
dataSource: portals,
readDataSource: true
}
}
});
function getMonthforFile(){
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var now = new Date();
var thisMonth = months[now.getMonth()];
var year = now.getFullYear();
var monthyear = thisMonth +' ' + year;
return monthyear;
}
以下是管理门户视图代码
<?php require APPROOT . '/views/inc/header.php'; ?>
<h1><?php echo $data['title']; ?></h1>
<div id="adminFlex">
<?php require APPROOT . '/views/inc/navadmin.php'; ?>
<div id="adminDashBoard" class="dashboard">
<script type="text/x-shield-template" id="portalEditTemplate">
<a class="btn btn-info" href="/portals/edit/{portalID}">Edit</a>
</script>
<script type="text/x-shield-template" id="portalDeleteTemplate">
<button type="button" class="btn btn-danger" id="delete" data-target="#confirmDeletePortal" data-toggle="modal" data-portalid="{portalID}">Delete</button>
</script>
<div class="row">
<div id="manageportalsgrid" class="center">
</div>
<button class="btn-info" onclick="refreshManagePortalData()">Refresh Portals</button>
<button class="btn-danger" data-target="#confirmDeleteAllPortals" data-toggle="modal">Delete All Portals</button>
</div>
<!-- Delete portal by ID Modal -->
<div class="modal fade" id="confirmDeletePortal" tabindex="-1" role="dialog" aria-labelledby="confirmDeletePortalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmDeletePortalLabel">Delete portal?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this portal?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<form action="<?php echo URLROOT; ?>portals/delete/" method=post>
<input type="hidden" id="delportalID" name="portalID" value="">
<input type="submit" class="btn btn-danger" name="action" value="delete"/>
</form>
</div>
</div>
</div>
</div>
<!-- Delete All Portals Modal -->
<div class="modal fade" id="confirmDeleteAllPortals" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteAllPortalsLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmDeleteAllPortalsModalLabel">Delete All Portals?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete all the portals?
</div>
<div class="modal-footer">
<form action="<?php echo URLROOT; ?>portals/clear/" method=post>
<button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
<input type="submit" name="yes" value="yes" class="btn btn-primary"/>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require APPROOT . '/views/inc/footer.php'; ?>
删除
刷新门户
删除所有门户
删除门户?
&时代;
是否确实要删除此门户?
不
我的问题是它只导出当前页面,而不是整个记录集。文档中说,您应该将readDataSource设置为true,这样做,但它不起作用
提前感谢您的帮助。如果数据源和/或其变量相同,我认为readDataSource选项将被忽略。我复制了portals数据源并复制了exportportals,如下所示:
var portals = new shield.DataSource({
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
var exportportals = new shield.DataSource({
remote: {
read: {
type: "POST",
url: "/portals/ajax"
}
}
});
然后我分别更改了网格和导出数据源的数据源:
$("#manageportalsgrid").shieldGrid({
dataSource: portals,
sorting: {
multiple: true
},
selection: {
type: "row",
multiple: true,
toggle: false
},
filtering: {
enabled: true
},
paging: true,
columns: [
{ field: "portalID", width: "130px", title: "Portal ID" },
{ field: "overx", width: "130px", title: "Overworld X" },
{ field: "overy", width: "130px", title: "Overworld Y" },
{ field: "overz", width: "130px", title: "Overworld Z" },
{ field: "netherx", width: "130px", title: "Nether X" },
{ field: "nethery", width: "130px", title: "Nether Y" },
{ field: "netherz", width: "130px", title: "Nether Z" },
{ field: "portalowner", width: "130px", title: "Portal Owner"},
{ field: "description", width: "130px", title: 'Portal Description'},
{
field:"actions",
width: "200px",
title:"Actions",
columnTemplate: $("#portalEditTemplate").html() + $("#portalDeleteTemplate").html()
}
],
toolbar: [
{
buttons: [
{
commandName: "csv",
caption: '<span class="sui-sprite sui-grid-icon-export-csv"></span> <span class="sui-grid-button-text">Export to CSV</span>'
}
]
}
],
exportOptions: {
proxy: "/attachments/save",
csv: {
fileName: "Viikis Community Server portals " + getMonthforFile(),
dataSource: exportportals,
readDataSource: true
}
}
});
$(“#manageportalsgrid”).shieldGrid({
数据源:门户,
分类:{
多重:对
},
选择:{
键入:“行”,
多重:对,
切换:false
},
筛选:{
已启用:true
},
是的,
列:[
{字段:“portalID”,宽度:“130px”,标题:“Portal ID”},
{字段:“overx”,宽度:“130px”,标题:“Overworld X”},
{字段:“overy”,宽度:“130px”,标题:“Overworld Y”},
{字段:“overz”,宽度:“130px”,标题:“Overworld Z”},
{字段:“阴X”,宽度:“130px”,标题:“阴X”},
{字段:“阴”,宽度:“130px”,标题:“阴”},
{字段:“虚空”,宽度:“130px”,标题:“虚空Z”},
{字段:“门户所有者”,宽度:“130px”,标题:“门户所有者”},
{字段:“描述”,宽度:“130px”,标题:“门户描述”},
{
字段:“操作”,
宽度:“200px”,
标题:“行动”,
columnTemplate:$(“#portalDeleteTemplate”).html()+$(“#portalDeleteTemplate”).html()
}
],
工具栏:[
{
按钮:[
{
命令名:“csv”,
标题:“导出到CSV”
}
]
}
],
出口选择:{
代理:“/attachments/save”,
csv:{
文件名:“Viikis社区服务器门户”+getMonthforFile(),
数据源:ExportPortal,
readDataSource:true
}
}
});
现在网格显示分页,导出时所有记录都被导出
$("#manageportalsgrid").shieldGrid({
dataSource: portals,
sorting: {
multiple: true
},
selection: {
type: "row",
multiple: true,
toggle: false
},
filtering: {
enabled: true
},
paging: true,
columns: [
{ field: "portalID", width: "130px", title: "Portal ID" },
{ field: "overx", width: "130px", title: "Overworld X" },
{ field: "overy", width: "130px", title: "Overworld Y" },
{ field: "overz", width: "130px", title: "Overworld Z" },
{ field: "netherx", width: "130px", title: "Nether X" },
{ field: "nethery", width: "130px", title: "Nether Y" },
{ field: "netherz", width: "130px", title: "Nether Z" },
{ field: "portalowner", width: "130px", title: "Portal Owner"},
{ field: "description", width: "130px", title: 'Portal Description'},
{
field:"actions",
width: "200px",
title:"Actions",
columnTemplate: $("#portalEditTemplate").html() + $("#portalDeleteTemplate").html()
}
],
toolbar: [
{
buttons: [
{
commandName: "csv",
caption: '<span class="sui-sprite sui-grid-icon-export-csv"></span> <span class="sui-grid-button-text">Export to CSV</span>'
}
]
}
],
exportOptions: {
proxy: "/attachments/save",
csv: {
fileName: "Viikis Community Server portals " + getMonthforFile(),
dataSource: exportportals,
readDataSource: true
}
}
});