zoukankan      html  css  js  c++  java
  • DataGrid首次进入页面时,不加载任何数据[转]

    首次不加载数据问题,必须搞明白如何才能不加载数据。根据Easu UI的官方API: http://www.jeasyui.com/documentation/

    仔细观察DataGrid的事件当中有一个这样的描述:

     

    根据这个我们给onBeforeLoad事件绑定如下的事件:

    onBeforeLoad: function (param) {
                    var firstLoad = $(this).attr("firstLoad");
                    if (firstLoad == "false" || typeof (firstLoad) == "undefined")
                    {
                        $(this).attr("firstLoad","true");
                        return false;
                    }
                    return true;
                }

    这段代码的主要意思就是:去查找当前datagrid的属性firstLoad,如果是false或者没有,那么返回false。同时设置firstLoad属性为true,否则的话(认为是true)就返回true.
    很显然第一次加载的时候默认肯定是没有这个属性的,那就会返回false。根据API我们已经知道,如果该事件返回false,datagrid就不会加载数据,从而在实现第一次不加载数据。而第二次的的时候firstLoad已经被设置为true,所以它会返回true,datagrid就会加载数据. 同时如果手动给table加上了firstLoad属性为true,那么datagrid也还是会在第一次加载时就load数据。

    小例子:

    $('#dg').datagrid({
          title: "合同交互",
          fit: true,
          queryParams: {
              BeginTime: $('#date_beginTime').datetimebox("getValue"),
              EndTime: $('#date_endTime').datetimebox("getValue"),
          },
          rownumbers: true,
          pagination: true,
          url: "/Contract/IPRequestsContractListByApplyId",
          pageSize: 20,
          singleSelect: true,
          columns: [
                     [
                        { field: "AddTime", title: "添加时间",  150, align: "center" },
                        { field: "Url", title: "访问地址",  1100, align: "center" },
                        { field: "ExceptionMessage", title: "异常信息",  300, align: "center" },
                        { field: "OutputContent", title: "输出内容",  1000, align: "center" },
                        { field: "Duration", title: "访问耗时",  100, align: "center" },
                        { field: "ip", title: "访问IP",  150, align: "center" }
                    ]
                ],
          onBeforeLoad: function (param) {
                    var firstLoad = $(this).attr("firstLoad");
                    if (firstLoad == "false" || typeof (firstLoad) == "undefined")
                    {
                        $(this).attr("firstLoad","true");
                        return false;
                    }
                    return true;
                }
    
         });
  • 相关阅读:
    CentOS/RedHat安装Python3
    Hash校验工具、MD5 SHA1 SHA256命令行工具
    centos如何安装Python3
    iOS之UI--涂鸦画板实例
    iOS之UI--Quartz2D的入门应用-- 重绘下载圆形进度条
    Eclipse导入项目: No projects are found to import
    在MAC平台下使用Eclipse出现了中文乱码
    C语言错误之--初始值(低级错误)
    iOS开发之duplicate symbols for architecture x86_64错误
    C语言的传值与传址调用
  • 原文地址:https://www.cnblogs.com/q1359720840/p/10509214.html
Copyright © 2011-2022 走看看