/*
 * 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;
 }
}

一个easyui的案例(SSH)相关推荐

  1. 一个多线程死锁案例,如何避免及解决死锁问题

    转载自 一个多线程死锁案例,如何避免及解决死锁问题 多线程死锁在java程序员笔试的时候时有遇见,死锁概念在之前的文章有介绍,大家应该也都明白它的概念,不清楚的去翻看历史文章吧. 下面是一个多线程死锁 ...

  2. zemax光学设计超级学习手册_穿越十年的一个ZEMAX光学设计案例

    目前超过两千人的光学与光学设计方面的微信公众号,欢迎您! 穿越十年的一个ZEMAX光学设计案例 作者:窗台小绿萝 CAD,这个词已经深入到学习.工作很多年,翻译过来就是Computer Aided D ...

  3. 一个Python爬虫案例让你看清Python2和3之间的区别

    随着Python越来越受欢迎了,也越来越多的人加入到这个大家庭当中,有很多的初学者都会有一个疑问,我学习Python是学习2版本的呢还是3版本的呢?Python2和Python3又有什么区别呢? 我想 ...

  4. 使用go的ssh包快速打造一个本地命令行ssh客户端

    2019独角兽企业重金招聘Python工程师标准>>> 热身运动? 在开始之前,先来个热身运动.虽然标题党写着快速打造一个ssh客户端,但是和跑步一样,在运动前还是需要先热身一下,不 ...

  5. 一个自动化测试的案例之记事狗微博篇

    一个自动化测试的案例之记事狗微博篇 前言: 针对于我这个学计算机的孩子,总是希望能够增强动手能力,在机子小小感冒时,能够自己帮它治愈,但现实情况是我总是把它搞成重病患者,貌似每次的动手能力,都让我的机 ...

  6. 数据挖掘时功能和一个聚类分析应用案例

    数据挖掘时功能和一个聚类分析应用案例 数据挖掘的常用方法和数据挖掘的重要功能(出自MBA智库百科).当然,横看成岭侧成峰,这些常用方法和重要功能也许并不完全正确或完整.除此以外,笔者尝试学习了SMAR ...

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

    在今天的博文中,笔者整理了数据挖掘的常用方法和数据挖掘的重要功能(出自MBA智库百科).当然,横看成岭侧成峰,这些常用方法和重要功能也许并不完全正确或完整.除此以外,笔者尝试学习了SMARTBI公司中 ...

  8. python实现输入一个正整数_Python中实现输入一个整数的案例

    我就废话不多说了,大家还是直接看代码吧! #! usr/bin/python3.5 # -*- coding:utf-8 -*- a = input("请输入一个整数:") #py ...

  9. iOS 7最佳实践:一个天气App案例

    转自:sjpsega's Blog iOS7最佳实践:一个天气App案例(一) iOS7最佳实践:一个天气App案例(二) 注:本文译自:raywenderlich ios-7-best-practi ...

最新文章

  1. 如何成为python 数据分析师_如何成为一名真正的数据分析师或者数据工程师
  2. IIS7 上配置运行 Ruby CGI环境
  3. shell脚本常用的4种流程控制语句
  4. rs485调试软件_【乐创“芯”说】你想知道的RS485
  5. linux elf 文件查看工具 readelf
  6. 较简单的字节输入流输出流拷贝文件
  7. 全链路压测一招搞定,阿里云性能测试铂金版发布
  8. VTP冲突的排查与解决
  9. Nginx+php+mysql+wordpress搭建自己的博客站点
  10. 2021年高压电工模拟考试题及高压电工模拟考试题库
  11. HFSS对称阵子仿真(2)
  12. 如何看懂EMC测试报告
  13. 沈阳农业大学计算机专业排名,沈阳农业大学王牌专业排名
  14. linux mplayer rpm,mplayer - movie player for linux
  15. 抖音04开头xgorgon、xlog、设备注册算法
  16. windows功能_【各种功能升级】微信windows版v2.9新体验
  17. 概念:蓝筹主板创业板新三板科创板
  18. 医用电气设备中关于电源开关的符号使用要求探讨
  19. qlist 嵌套_QList内存释放
  20. 通过网页或者移动设备链接跳转qq(tim)添加好友(群)

热门文章

  1. 爬虫笔记:Urllib库详解
  2. VTK:绘制bottle瓶子用法实战
  3. wxWidgets:wxTextCompleterSimple类用法
  4. boost::safe_numerics模块有理数示例程序
  5. boost::hana::remove_range用法的测试程序
  6. bgi::detail::comparable_margin用法的测试程序
  7. VTK:Snippets之RestoreSceneFromFile
  8. VTK:几何对象之OrientedArrow
  9. OpenCV cv :: UMat与DirectX10曲面的互操作性的实例(附完整代码)
  10. QDoc包括外部代码includingexternalcode