一个easyui的案例(SSH)

/*
 * name :tuzuoquan mail :tuzq@css.com.cn date :2014/02/14 version :0.1
 * description:气象信息共享门户系统通用JS,TreeTable CopyRight (C) 2014-02
 */
// 获取选中一行的情况,下面的一个参数可以代表一个DataGrid
function getSelected(dialogEle) {
 // 获取选中一行的情况。
 var datagrid = $("#fileInfoDataGrid").datagrid('getSelected');
// alert(datagrid.fileName + " " + datagrid.filePath + " "
//   + datagrid.lastModified + " " + datagrid.fileType);
 if(datagrid == null){
  alert("对不起!您还没有选择文件!");
 } else {
  if(datagrid.fileType == "文件夹"){
   alert("对不起,您选择的是文件夹,请您选择确切的文件!");
  } else {
   //alert($(".service1 #path").length);
   //给这个文本域赋值
   $(".service1 #path").attr("value",datagrid.filePath);
   dialogEle.dialog("close");
  }
 }
}

// 获取选中多行的情况
function getSelections() {
 var ids = [];
 var rows = $("#fileInfoDataGrid").datagrid('getSelections');
 for (var i = 0; i < rows.length; i++) {
  ids.push(rows[i].filePath);
 }

 alert(ids.join(':'));
}

//选中指定行
function selectRow(rowNum){
 $("#fileInfoDataGrid").datagrid('selectRow',rowNum);
}

//不选中指定行
function unselectRow(rowNum){
 $("#fileInfoDataGrid").datagrid('unselectRow',rowNum);
}

function clearSelections(){
 $("#fileInfoDataGrid").datagrid('clearSelections');
}

$(function() {
 $("#dialog-diskFileInfo").dialog({
  resizable : false,
  height : 500,
  minHeight : 150,
  width : 1015,
  modal : true,
  show : "blind",
  hide : "explode",
  closeOnEscape : true,
  autoOpen : false,
  draggable : true,
  buttons : {
   "确定" : function() {
    $.fn.diskFileDialogEleBtnCheckOk($(this),
      $("#diskFileStructureTree"), $("#fileInfoDataGrid"));
   },
   "取消" : function() {
    $(this).dialog("close");
   }
  }
 });

 // 带有class属性为openDiskFileInfoDialog的元素,为这个元素添加点击事件
 $("#openDiskFileInfoDialog").bind("click", function() {
  // 加载数据
  $("#diskFileStructureTree").tree({
   height : 355,
   checkbox : false,
   url : basePath + "/onlinegraph/treeDataAction_treeNodes.action",
   method : 'post',
   animate : true,
   dnd : true,
   lines : true,
   onClick : function(node) {
//    $("#fileInfoDataGrid").datagrid({
//     // 通过这个获得参数
//     url : basePath
//       + "/onlinegraph/fileInfoAction_folderFileInfoList.action?path=" + node.id,
//     method : 'post'
//    });
    
    $("#fileInfoDataGrid").datagrid('load', {
       page : 1,
       pageSize : "10",
       path:node.id
      });
    
    //$("#fileInfoDataGrid").datagrid('reload');
   },
   onBeforeExpand : function(node, param) {
    $("#diskFileStructureTree").tree('options').url = basePath
      + "/onlinegraph/treeDataAction_treeNodeList.action?path="
      + node.id;
   }
  });

  // 打开表格
  $("#fileInfoDataGrid").datagrid({
   height:325,
   width:815,
   // 通过这个获得参数
   url : basePath
     + "/onlinegraph/fileInfoAction_folderFileInfoList.action",
   // 行阴影,但目前看没有效果
   striped : true,
   method : 'post',
   nowrap : false,
   border : false,
   singleSelect : true,
   // 自适应窗口大小变化
   fit : true,
   title : '文件信息',
   fitColumns : true,
   rownumbers : true,
   idField : 'filePath',
   collapsible : true,
   sortName:'fileName',
   // 排序规则
   sortOrder : 'desc',
   // 本地排序,不是在服务器端排
   remoteSort : false,
   frozenColumns : [[{
      field : 'checkbox',
      checkbox : true
     }]],
   columns : [[{
      field : 'fileName',
      title : '名称',
      sortable : true,
      sortable : true,
      width : 50
     }, {
      field : 'filePath',
      title : '文件路径',
      sortable : true,
      sortable : true,
      width : 160
     }, {
      field : 'lastModified',
      title : '修改日期',
      sortable : true,
      sortable : true,
      width : 100
     }, {
      field : 'fileType',
      title : '类型',
      sortable : true,
      width : 50,
      align : 'left'
     }, {
      field : 'fileSize',
      title : '大小',
      sortable : true,
      width : 50,
      align : 'left'
     }]],
   // 事件调用的方式
   onLoadSuccess : function() {
   },
   onDblClickRow:function(index,row){
    //alert("index == " + index + " row == " + row.filePath);
    
    if(row.fileType == "文件夹"){
     alert("对不起,您选择的是文件夹,请您选择确切的文件!");
    } else {
     //alert($(".service1 #path").length);
     //给这个文本域赋值
     $(".service1 #path").attr("value",row.filePath);
     $("#dialog-diskFileInfo").dialog("close");
    }
   },
   pagination : true
  });

  var p = $("#fileInfoDataGrid").datagrid('getPager');
  $(p).pagination({
   pageList:[5,10,20,30,40,50,100],
   //layout:['list','sep','first','prev','links','next','last','sep','refresh'],
   beforePageText : '第',
   afterPageText : '页  共{pages}页',
   displayMsg : '当前显示 {from} - {to} 条记录   共 {total} 条记录',
   showPageList:true,
   showRefresh:true,
   onSelectPage : function(pageNumber, pageSize) {
    $(this).pagination('loading');
    $(this).pagination('loaded');
    
    // 选择相应的页码时刷新显示内容列表
    $("#fileInfoDataGrid").datagrid('load', {
       page : pageNumber,
       pageSize : pageSize
      });

    $("#fileInfoDataGrid").datagrid('reload');

    // $("#fileInfoDataGrid").datagrid({
    // //通过这个获得参数
    // url: basePath +
    // "/onlinegraph/fileInfoAction_folderFileInfoList.action?page="
    // + pageNumber + "&pageSize=" + pageSize,
    // method:'post'
    // });
   },
   onBeforeRefresh : function(pageNumber, pageSize) {
    // 刷新触发事件
    $(this).pagination('loading');
    $(this).pagination('loaded');
   },
   onRefresh : function(pageNumber, pageSize) {
    //alert("pageNumber = " + pageNumber + " pageSize = " + pageSize);
    // 上一页触发事件
    $("#fileInfoDataGrid").datagrid('load', {
       page : pageNumber,
       pageSize : pageSize
      });

    $(this).pagination('loading');
    $(this).pagination('loaded');

    $("#fileInfoDataGrid").datagrid('reload');
   },
   onChangePageSize : function(pageSize) {
    $(this).pagination('loading');
                $(this).pagination('loaded');
   }
  });

  $("#dialog-diskFileInfo").dialog("open");
 });

 // 插件的第一个参数表示的是弹出的dialog元素
 $.fn.diskFileDialogEleBtnCheckOk = function(dialogEle,
   diskFileStructureTree, fileInfoDataGrid) {

  // 获得选中列
  getSelected(dialogEle);
    
  //获取选中多行的信息
  //getSelections();
  
  //选中第二行
  //selectRow(2);
    
  //不选中第三行
  //unselectRow(2);
  
  //清除所有的选中行
  //clearSelections();
 }
});

 

struts2配置:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 <package name="system_onlinegraph" namespace="/onlinegraph" extends="global-struts-default">
  <action name="treeDataAction_*" class="cn.com.css.misps.onlinegraph.web.action.TreeDataAction" method="{1}">
   <result name="treeNodes" type="json">
    <param name="root">treeList</param>
   </result>
   <result name="treeNodeList" type="json">
    <param name="root">treeNodeList</param>
   </result>
  </action>
  
  <action name="fileInfoAction_*" class="cn.com.css.misps.onlinegraph.web.action.FileInfoAction" method="{1}">
   <result type="json"></result>
  </action>
    </package>
</struts>

 

 

 

action的写法:

package cn.com.css.misps.onlinegraph.web.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.com.css.common.action.BaseAction;
import cn.com.css.misps.onlinegraph.bean.TreeDataBean;
import cn.com.css.misps.onlinegraph.service.ITreeDataService;
import cn.com.css.misps.onlinegraph.service.impl.TreeDataServiceImpl;
import cn.com.css.misps.onlinegraph.util.ProductsStorageUtils;

/**
 * @brief FileInfoAction.java 通过这个类查看文件夹下的文件信息
 * @attention
 * @author 涂作权
 * @date 2014-2-25
 * @note begin modify by null
 */
@SuppressWarnings("serial")
@Scope("prototype")
@Controller
public class FileInfoAction extends BaseAction {
 private int total = 0;
 private List<Object> rows;
 private String path;
 private String page;
 private String pageSize;
 
 /**
  * \brief 通过此方法返回指定文件夹下的文件信息
  *
  * @return
  * @attention
  * @author 涂作权
  * @date 2014-2-25
  * @note begin modify by null
  */
 public String folderFileInfoList() {
  rows = new ArrayList<Object>();
  ITreeDataService treeDataService = new TreeDataServiceImpl();

  // 如果path为空,显示的是根目录的文件信息
  List<TreeDataBean> list = null;
  
  //先获得当前页和每页大小,如果在
  int intPage = Integer.parseInt((page == null || page == "0") ? "1":page);
  System.out.println("intPage  ==  "+intPage);
  
  if (path == null) {
   // 如果path为空,显示的是根目录的文件信息
   list = treeDataService.getAllFileList(ProductsStorageUtils.micapsAbsolutePath);
  } else {
   // 如果文件路径是空,查询指定目录下的文件信息
   list = treeDataService.getAllFileList(path);
  }
  
  //每页显示条数
  int number = Integer.parseInt((pageSize == null || pageSize == "0") ? "10":pageSize);
  
  if ((pageSize == null || pageSize == "0")) {
   pageSize = "10";
   page = "1";
  }
  
  //每页的开始记录  第一页为1, 第二页为number+1
  int start = (intPage - 1) * number;
  int end = ((start + number) < list.size()) ? start + number : list.size();
  
  //注意要将每个对象的内容放到map集合中,然后将每个map放到rows集合中
  for (int i = start; i < end; i++) {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("fileName", list.get(i).getFileName());
   map.put("filePath", list.get(i).getFilePath());
   map.put("lastModified", list.get(i).getLastModified());
   map.put("fileType", list.get(i).getFileType());
   map.put("fileSize", list.get(i).getFileSize());
   rows.add(map);
  }
  
  total = list.size();
  
  return SUCCESS;
 }

 /**
  * @return the total
  */
 public int getTotal() {
  return total;
 }

 /**
  * @param total the total to set
  */
 
 public void setTotal(int total) {
  this.total = total;
 }

 /**
  * @return the rows
  */
 public List<Object> getRows() {
  return rows;
 }

 /**
  * @param rows the rows to set
  */
 
 public void setRows(List<Object> rows) {
  this.rows = rows;
 }

 /**
  * @return the path
  */
 public String getPath() {
  return path;
 }

 /**
  * @param path the path to set
  */
 
 public void setPath(String path) {
  this.path = path;
 }

 /**
  * @return the page
  */
 public String getPage() {
  return page;
 }

 /**
  * @param page the page to set
  */
 
 public void setPage(String page) {
  this.page = page;
 }

 /**
  * @return the pageSize
  */
 public String getPageSize() {
  return pageSize;
 }

 /**
  * @param pageSize the pageSize to set
  */
 
 public void setPageSize(String pageSize) {
  this.pageSize = pageSize;
 }
}

时间: 2024-07-28 15:26:45

一个easyui的案例(SSH)的相关文章

.net-easyui从mvc加载另一个easyui的datarid视图样式没了

问题描述 easyui从mvc加载另一个easyui的datarid视图样式没了 控制台报错了 报错信息 XMLHttpRequest cannot load http://localhost:1674/702766cf82f645aab8494ad7fdcf3e2c/browserLink. Origin http://localhost:3121 is not allowed by Access-Control-Allow-Origin. localhost:3121/:1 Uncaught

一个easyui datebox 的取值问题

问题描述 一个easyui datebox 的取值问题 我用setValue设置datebox默认为今天,之后在onSelect将变化赋值给一个隐藏域, 为啥这个隐藏域的值就获取不到了呢?求教...头发都快抓掉了~~谢谢 解决方案 你的代码呢?还有如何取值的?服务器端还是客户端? 解决方案二: function dateBoxValue(){ var curr_time = new Date(); var cury= curr_time.getFullYear(); var curm=curr_

请教一个easyui -datagrid-detailview onExpandRow事件失效的问题

问题描述 请教一个easyui -datagrid-detailview onExpandRow事件失效的问题 第一次加载数据的时候可以展开当点击查询之后, +号 失效, 在线求解. 解决方案 这个得看你里面具体代码怎么写的, 查询之后那个+号事件还存在不?其次你的画面有没有js 出现错误 解决方案二: 这个要看你的查询事件怎么写的了,看看控制台有没有js报错,报错会阻止事件执行 解决方案三: f12打开浏览器开发工具看报什么错误

数据挖掘的常用方法、功能和一个聚类分析应用案例

在今天的博文中,笔者整理了数据挖掘的常用方法和数据挖掘的重要功能(出自MBA智库百科).当然,横看成岭侧成峰,这些常用方法和重要功能也许并不完全正确或完整.除此以外,笔者尝试学习了SMARTBI公司中的Smart Mining软件,并跟随其提供的示例教程进行了学习.为方便阅读,将其示例教程结合自己的体会作为文章的第三部分. 一.数据挖掘的常用方法 利用数据挖掘进行数据分析常用的方法主要有分类.回归分析.聚类.关联规则.特征.变化和偏差分析.Web页挖掘等,它们分别从不同的角度对数据进行挖掘. 分

一个MySQL优化案例的初步思路

今天想起这件同事处理的一个性能优化案例,当时虽然解决了,但是还是留下了几个未解的问题,和大家一起讨论一下. 首先,这个问题是根据反馈sql响应很慢,已经开始影响前端应用的登录了.稍后DBA介入,发现是由于CPU使用率过高导致,为了能够延缓问题和进一步分析,因为数据库中的数据量不大,直接就迁移到了另外一台配置不错的服务器上,但是迁移之后,CPU配置好了很多,问题依旧,同时也在进行问题的诊断和分析. 得到的慢日志如下,发现大多数的响应时间都耗费在了两个SQL上,其实出自同一个存储过程. 1.慢日志

市场判断失败剖析一个失败创业案例

2007年上半年即将结束的时候,传来一个消息,原来从公司出去的几个同事合伙创业的一个建筑软件企业解散了,这个企业是在2006年初,公司中以老王为主的一些销售人员禁不住这个市场的诱惑组建起来的,做一些关于施工技术类产品的同质化竞争. 建筑软件市场也许还能算得上是国内商品化软件市场的运作得比较成功的一块市场,全国有众多的软件企业在这个领域中打拼,并扶持着这个算得上是国内软件市场中的一块净土.在这个领域中,大部分企业的竞争力还不强,软件研发管理模式.软件创新能力与一些软件巨头相比,还相差甚远. 国内不

如何搭建一个物联网商业案例的解读

我们中的很多人都经历过没有互联网的时代,但是现在正是技术变革的时候,尽管我们还不如这一切是怎么发生的.可以说今天的互联网也刚刚开始,它还将不断的向各方面扩展,成本不断降低的传感器每天会产生大量的数据,这会推动网络的指数级壮大,并且影响我们的日常生活. 网络设备制造商Cisco公司认为物联网(IoT)充分利用了互联网各种通信协议,在家里或者办公室的设备如PC.机顶盒和智能仪表,移动网络中的智能手机和M2M调制解调器会产生数以亿计的数据包,这些形成了一个使用公共基础设施的包括万亿终端设备的网络.但是

一个完整的案例

我们现在要做一个杂志订阅系统,要用户输入Email,输入两次密码,密码要一样,密码要求安全,所以必须包括(!@#$%^&*+;:),输入用户的电话,最长20位,必须选择信用卡,输入卡号,卡号为15位,程序如下,好简单的,大家看看. <% public sub OnSubmit(source as Object, e as EventArgs) if Page.IsValid then "数据入库等操作 end if end sub%><h3><font fa

一个HBase优化案例分析:Facebook Messages系统问题与解决方案

HDFS设计的初衷是为了存储大文件(例如日志文件),面向批处理.顺序I/O的.然而架设在HDFS之上的HBase设计的初衷却是为了解决海量数据的随机读写的请求.把这两种设计初衷截然相反的组件怎么揉在一起的呢?这种分层的结构设计主要是为了使架构更清晰,HBase层和HDFS层各司其职:但是却带来了潜在的性能下降.在很多业务场景中大家使用HBase抱怨最多的两个问题就是:Java GC相关的问题和随机读写性能的问题.Facebook Messages(以下简称FM系统)系统可以说是HBase在onl