从 Shield UI Grid 导出所有记录

如何解决从 Shield UI Grid 导出所有记录

我正在尝试从数据网格中导出所有数据。盾牌 UI 示例演示确实导出了所有记录,所以我知道它可以完成!当我这样做时,它只导出当前页面数据!

Java 代码片段:

    
    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",title: "Overworld X" },{ field: "overy",title: "Overworld Y" },{ field: "overz",title: "Overworld Z" },{ field: "netherx",title: "Nether X" },{ field: "nethery",title: "Nether Y" },{ field: "netherz",title: "Nether Z" },{ field: "portalowner",title: "Portal Owner"},{ field: "description",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脚本,输出:

[{"portalID":"2","netherx":"63","nethery":"32","netherz":"-69","overx":"500","overy":"59","overz":"-550","description":"Carley_Guys Base","owner":"2","userID":"2","portalowner":"carley_guy"},{"portalID":"3","netherx":"66","netherz":"112","overx":"531","overy":"57","overz":"892","description":"Krons Portal","owner":"3","userID":"3","portalowner":"Kron"},{"portalID":"4","netherx":"-19","netherz":"-79","overx":"-150","overy":"64","overz":"-629","description":"Rosysian's Home","owner":"4","userID":"4","portalowner":"Rosysian"},{"portalID":"5","netherx":"-22","netherz":"97","overx":"-178","overz":"776","description":"Budmeister's Portal","owner":"5","userID":"5","portalowner":"Budmeister91"},{"portalID":"6","netherx":"100","netherz":"51","overx":"796","overy":"53","overz":"406","description":"Tired_Luvs Portal","owner":"6","userID":"6","portalowner":"Tired_Luvs"},{"portalID":"7","netherx":"47","nethery":"56","netherz":"-68","overx":"378","overz":"-547","description":"","owner":"7","userID":"7","portalowner":"EdenShieldex"},{"portalID":"9","netherx":"50","netherz":"11","overx":"401","overy":"80","overz":"89","owner":"10","userID":"10","portalowner":"thewookie0"},{"portalID":"10","netherx":"165","nethery":"35","netherz":"139","overx":"1317","overy":"63","overz":"1113","description":"Viikis Jungle Portal","owner":"8","userID":"8","portalowner":"Viiki"},{"portalID":"11","netherx":"333","netherz":"331","overx":"2661","overy":"68","overz":"2650","description":"Dummy Portal Beths Adventure",{"portalID":"12","netherx":"-32","netherz":"43","overx":"-256","overy":"81","overz":"340","description":"egidasha's portal","owner":"31","userID":"31","portalowner":"egidasha"},{"portalID":"13","netherx":"-58","nethery":"34","netherz":"-7","overx":"-464","overy":"71","overz":"-52","description":"Psylences Portal","owner":"23","userID":"23","portalowner":"Psylence33"},{"portalID":"14","netherx":"-33","netherz":"25","overx":"-262","overy":"77","overz":"199","description":"Viikis Portal Near Spawn",{"portalID":"15","netherx":"-41","netherz":"26","overx":"-330","overz":"206","description":"Pengdonuts Portal","owner":"19","userID":"19","portalowner":"PengDonut"},{"portalID":"16","netherx":"-24","netherz":"-112","overx":"-193","overz":"-898","description":"RocWolfes Portal","owner":"14","userID":"14","portalowner":"RocWolfe"},{"portalID":"17","netherx":"32","netherz":"-133","overx":"256","overz":"-1066","description":"MysteryMuffins' Portal","owner":"11","userID":"11","portalowner":"meepymuffins"},{"portalID":"18","netherz":"83","overy":"105","overz":"663","description":"Moi33","owner":"25","userID":"25","portalowner":"MoiXtra"},{"portalID":"19","netherx":"-56","netherz":"21","overx":"-450","overy":"51","overz":"166","description":"Jerv's Portal","owner":"21","userID":"21","portalowner":"jervi_servi"},{"portalID":"20","netherx":"19","netherz":"12","overx":"154","overy":"66","overz":"98","description":"Br3admakesufat's Portal","owner":"24","userID":"24","portalowner":"BR3ADMAKESUFAT"},{"portalID":"22","netherx":"96","netherz":"113","overx":"771","overy":"65","overz":"906","description":"BentlyEU's Portal","owner":"26","userID":"26","portalowner":"bentley"},{"portalID":"23","netherx":"60","netherz":"78","overx":"483","overz":"621","description":"hozbombs Portal","owner":"29","userID":"29","portalowner":"hozbomb"},{"portalID":"24","netherx":"-8","netherz":"5","overx":"-64","overy":"96","overz":"36","description":"sushis Portal","owner":"27","userID":"27","portalowner":"thereal_sushi"},{"portalID":"25","netherx":"-64","netherz":"68","overx":"-509","overy":"72","overz":"547","description":"ikxrleys Portal","owner":"32","userID":"32","portalowner":"ikxrley"},{"portalID":"26","netherx":"-67","netherz":"-6","overx":"-532","overz":"-46","description":"wizard1011's Portal","owner":"30","userID":"30","portalowner":"superswag3211"},{"portalID":"27","netherx":"-50","netherz":"41","overx":"-400","overz":"324","description":"WW__WW's Portal",{"portalID":"28","netherx":"-44","netherz":"6","overx":"-352","overy":"67","overz":"51","description":"hippert02s Portal","owner":"33","userID":"33","portalowner":"hippert"},{"portalID":"29","netherx":"67","netherz":"50","overx":"535","overz":"398","description":"FaithfulSO3s Portal","owner":"28","userID":"28","portalowner":"ixfaithful"},{"portalID":"30","netherx":"156","netherz":"143","overx":"1245","overy":"11","overz":"1141","description":"Bud's Jungle Portal",{"portalID":"31","netherx":"192","netherz":"-252","overx":"1532","overz":"-2013","description":"VirusBB8's base","owner":"17","userID":"17","portalowner":"VirusBB8"},{"portalID":"32","netherx":"-150","netherz":"-151","overx":"-1197","overy":"22","overz":"-1205","description":"End Portal Room",{"portalID":"34","netherx":"244","netherz":"249","overx":"1950","overz":"1993","description":"NorwegianGreaser Home","owner":"22","userID":"22","portalowner":"NorwegianGreaser"},{"portalID":"35","nethery":"15","netherz":"54","overx":"-172","overy":"75","overz":"430","description":"LordPapi_s Portal","owner":"12","userID":"12","portalowner":"Lordpapi_"},{"portalID":"36","netherx":"642","netherz":"633","overx":"5133","overy":"70","overz":"5067","description":"Middle of the sea",{"portalID":"37","netherx":"548","netherz":"272","overx":"4385","overz":"2172","description":"Desert into soul sand valley","owner":"35","userID":"35","portalowner":"iamtehnub"},{"portalID":"38","netherx":"140","netherz":"56","overx":"1123","overz":"450","description":"Mountain biome port",{"portalID":"39","netherx":"405","netherz":"219","overx":"3237","overz":"1753",{"portalID":"43","netherx":"-110","netherz":"-130","overx":"-880","overy":"97","overz":"-1040","description":"TmacMusic's Base","owner":"1","userID":"1","portalowner":"TmacMusic"}]

这里是管理门户视图代码

<?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">&times;</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">&times;</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 选项将被忽略。我复制了门户数据源并制作了副本导出门户,如下所示:

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",title: "Overworld X" },{ field: "overy",title: "Overworld Y" },{ field: "overz",title: "Overworld Z" },{ field: "netherx",title: "Nether X" },{ field: "nethery",title: "Nether Y" },{ field: "netherz",title: "Nether Z" },{ field: "portalowner",title: "Portal Owner"},{ field: "description",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
                }
                
            }
        });

现在网格显示分页,导出时所有记录都被导出!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res