1. 程式人生 > >highcharts click事件獲取資料傳給datagrid ,動態載入資料

highcharts click事件獲取資料傳給datagrid ,動態載入資料

點選highcharts的柱子 會觸發click事件,並將資料傳給後臺獲取到相應部門下的所有員工資訊顯示在datagrid

如下:新增在charts的初始化裡

[java]  view plain  copy
  1. plotOptions : {  
  2.             series : {  
  3.                 cursor : 'pointer',  
  4.                 events : {  
  5.                     click : function(e) {  
  6.                         var value=e.point.id;  
  7.                         location.href ="user/showTable.shtml?id="
     +value;  
  8.                     }  
  9.                 }  
  10.             },  

這裡的e.point.id 是我再後臺返回json資料時 在jsonobject新增的  ,表明了部門的id編號,這樣後臺就可以根據id獲取該部門下的使用者

在後臺,json資料裡獲取到了一些value,會顯示上一篇的效果。

[java]  view plain  copy
  1. @RequestMapping(value="/getChartsJson" ,produces = "text/html;charset=UTF-8")  
  2.     @ResponseBody  
  3.     public String getJson() {  
  4.         /* 
  5.         JSONObject params = new JSONObject(); 
  6.         params.put("name", deptService.getDeptname()); 
  7.         params.put("count", userService.getDeptCountList()); 
  8.         */  
  9.         List<Integer> listcount=userService.getDeptCountList();  
  10.         List<String> listname=deptService.getDeptname();  
  11.         List<Integer> listdeptid=deptService.getDeptid();  
  12.           
  13.         JSONArray jsonarray=new JSONArray();  
  14.         for(int i=0;i<listcount.size();i++){  
  15.             JSONObject params = new JSONObject();  
  16.             params.put("name", listname.get(i));  
  17.             params.put("count", listcount.get(i) );  
  18.             params.put("id", listdeptid.get(i) );  
  19.               
  20.             jsonarray.add(i,params );  
  21.         }  
  22.         JSONObject json = new JSONObject();  
  23.         json.put("list", jsonarray);  
  24.         String s=json.toString();  
  25.         return s;  
  26.   
  27.     }  
  28.       

再點選柱子後 會調到後臺,目的是將我們獲取到該柱子所表示的部門id值傳入到要顯示datagrid的jsp中(這裡傳入到了table.jsp中)

[java]  view plain  copy
  1. @RequestMapping("/showTable")  
  2. public ModelAndView showTable(Integer id) throws Exception {   
  3.     ModelAndView mav = new ModelAndView("table");   
  4.     mav.addObject("id", id);  
  5.     return mav;  
  6. }  
table.jsp

[html]  view plain  copy
  1. <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>  
  2. <%  
  3.     String path = request.getContextPath();  
  4.     String basePath = request.getScheme() + "://"  
  5.             + request.getServerName() + ":" + request.getServerPort()  
  6.             + path + "/";  
  7. %>  
  8.   
  9. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  10. <html>  
  11. <head>  
  12. <base href="<%=basePath%>">  
  13.   
  14. <title>員工管理</title>  
  15.   
  16. <meta http-equiv="pragma" content="no-cache">  
  17. <meta http-equiv="cache-control" content="no-cache">  
  18. <meta http-equiv="expires" content="0">  
  19. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
  20. <meta http-equiv="description" content="This is my page">  
  21. <!-- 
  22.     <link rel="stylesheet" type="text/css" href="styles.css"> 
  23.     -->  
  24. <script type="text/javascript" src="jquery-easyui-1.4.4/jquery.min.js"></script>  
  25. <script type="text/javascript"  
  26.     src="jquery-easyui-1.4.4/jquery.easyui.min.js"></script>  
  27.   
  28. <script type="text/javascript" src="jquery-form.js"></script>  
  29. <link href="jquery-easyui-1.4.4/themes/default/easyui.css"  
  30.     rel="stylesheet" type="text/css" />  
  31. <link href="jquery-easyui-1.4.4/themes/icon.css" rel="stylesheet"  
  32.     type="text/css" />  
  33.   
  34. <link href="css/userdlg.css" rel="stylesheet" type="text/css" />  
  35.   
  36.   
  37.   
  38. <script type="text/javascript">  
  39. $(function () {  
  40.     $('#dgg').datagrid({  
  41.         // url:"user/showUser.shtml",  
  42.          //url:"user/showPageUser.shtml",  
  43.         url : "user/getUserByDeptno.shtml?id=" + ${id},  
  44.   
  45.         columns : [ [  {  
  46.             field : 'id',  
  47.             title : '編號',  
  48.             align : 'center',  
  49.             width : 60  
  50.         }, {  
  51.             field : 'userName',  
  52.             title : '使用者名稱',  
  53.             align : 'center',  
  54.             width : 60  
  55.         }, {  
  56.             field : 'age',  
  57.             title : '年齡',  
  58.             width : 60,  
  59.             align : 'center'  
  60.         }, {  
  61.             field : 'position',  
  62.             title : '職位',  
  63.             width : 60,  
  64.             align : 'center'  
  65.         }, {  
  66.             field : 'sex',  
  67.             title : '性別',  
  68.             width : 60,  
  69.             align : 'center'  
  70.         }, {  
  71.             field : 'deptno',  
  72.             title : '部門編號',  
  73.             width : 60,  
  74.             height:60,  
  75.             align : 'center'  
  76.         } ] ]  
  77.     });  
  78.     var p = $("#dgg").datagrid("getPager");  
  79.     $(p).pagination({  
  80.         pageSize : 10,// 每頁顯示的記錄條數,預設為10  
  81.         pageList : [ 5, 10, 15 ],// 可以設定每頁記錄條數的列表  
  82.         beforePageText : '第',// 頁數文字框前顯示的漢字  
  83.         afterPageText : '頁    共 {pages} 頁',  
  84.         displayMsg : '當前顯示 {from} - {to} 條記錄   共 {total} 條記錄',  
  85.   
  86.     });  
  87.       
  88. });  
  89.   
  90. </script>  
  91. </head>  
  92.   
  93.   
  94. 相關推薦

    highcharts click事件獲取資料datagrid 動態載入資料

    點選highcharts的柱子 會觸發click事件,並將資料傳給後臺獲取到相應部門下的所有員工資訊顯示在datagrid 如下:新增在charts的初始化裡 [java]  view plain  copy

    後端將Long型別的資料前端前端可能會出現精度丟失的情況及其解決方案

    1.問題描述: 後端將long型別資料傳給前端,前端解析時可能出現精度丟失的情況. 例如:後端資料:919059760869863424,到前端變成919059760869863400;又或如:918806410454654976--->918806410454654900表現為

    前臺通過js 寫個ajax請求把資料後臺然後後臺接收到這個資料 再儲存到資料庫。。

     //前端js操作: function testAjax(){ var url="/testAjaxUrlJson/";//後臺接收處理url var txtContent= "textprm";//傳輸內容;  var objData = [         { name

    在webcontent中新建的資料夾中建立的JSP無法將資料servlet

       相信很多寫程式的朋友都會建立很多資料夾來分類存放所寫的程式碼,本人也是如此,但是作為一個菜鳥,在做這件事的時候總會發生許多錯誤,我也一 一記錄下來,今次也不例外。    在寫一個關於登入頁面的簡單的JSP+Servlet時,新建立的資料夾,在裡面新寫

    jquery 一個form的資料另一個form

    將form資料序列化js物件js程式碼 // 將一個表單的資料返回成JS物件 $.fn.serializeObject = function() { var o =

    vue父元件調子元件 $refs (把父元件的資料子元件)

    父元件: <el-dialog title="" @close="refresh" :visible.sync="userRoleVisible" @open="showAuthEvent"> <user-role-panel ref="authP

    vue---父調子 $refs (把父元件的資料子元件)子調父 $emit (把子元件的資料父元件)

    ps:App.vue 父元件   Hello.vue 子元件 App.vue : <template> <div id="app"> <input type="

    通過Json格式將資料服務端

    1、匯入json相關的jar包,一共是6個,如果有需要jar包的歡迎大傢俬聊我! 2、在繼承HttpServlet類下面的doGet()方法中寫如下的程式                 request.setCharacterEncoding("utf-8");resp

    大資料量JSONObject.fromObject效能問題(大資料前臺)

    最近專案中我負責了一個jms列印log資訊的功能模組。大體需求是,用jms接受log資訊,然後前臺請求的時候,發給前臺最新的log資訊,前臺會不斷的重新整理獲取資料。 個人思路是寫一個靜態的固定長度的list儲存log資訊,如果list滿了清空。前臺第一次訪問的時候,返回給

    opencv將影象轉換成二維陣列再將陣列資料新影象

    #include<iostream> #include<fstream> #include "cv.h" #include "highgui.h" using namespac

    php的老兄客戶端[object object]資料如何解析但他堅稱是json...

    一般伺服器傳給客戶端的資料格式是json 。然後這個是js觸發之後,伺服器傳過來的,據說沒有jsonformat。。。。 然後就是這個東東: 直接列印或者強轉並不行,需要轉成dictionary來解析,toDictionary 這個方法是是Frameworks中的:Ja

    ajax動態載入資料後的click事件問題

    問: 為什麼ajax加載出來的html,無法用選擇器繫結事件,但可以直接在html上使用onclick等事件? 如ajax 載入了<div class="div">div</div> 然後$('.div').click(funct

    使用HttpRequest.Files 獲取文件實現上附件功能

    post 分享 new 失敗 light 查看 continue 存在 nbsp 使用HttpRequest.Files 獲取上傳文件,實現上傳附件功能,不同瀏覽器會有差異: 獲得在 Google 瀏覽器上傳後得到的 HttpRequest.Files (客戶端上載文件

    在asp.net mvc3 中在controller中使用HttpPostedFileBase file 引數獲取的檔案檔案路徑問題

    轉載:https://zhidao.baidu.com/question/444203596.html   在asp.net mvc3 中,在controller中使用HttpPostedFileBase file 引數獲取上傳的檔案,開始的時候file.filename獲取的為檔案的名稱,後來

    移動端將base64後臺後臺解析出的圖片一部分是白色的

    1、base64在手機端如果儲存到input的value裡面   input會截斷太大的部分 導致後臺收到的base64無法正確解析或者一部分是白色的   可以放到全域性變數或者imgsrc屬性裡  2、部

    datagrid動態載入資料分頁下載EasyUI外掛

    這是完整的前臺程式碼 <!DOCTYPE html> <html> <head id="Head1">     <title>StencilControl</title>     <script src="/

    Vue2.0父元件向子元件動態修改資料問題[props導致的問題]

    在Vue2.0中,專案開發時遇到的問題。 在子元件定義 <script> export default { props:['displaySelf'] } </script>

    $.ajax()前臺資料至後臺中文亂碼問題

    原因:對於在網路中傳輸的字元資料,不管其編碼為什麼,java總認為是“iso-8859-1”編碼,所以從前臺取到的資料如此處理:content = new String(前臺資料.getBytes("iso-8859-1"),"utf-8");//utf-8可以換成你程式設

    Jquery chosen動態設定值 select Ajax動態載入資料 設定chosen和獲取他們選中的值

      在做一個編輯對話方塊時,要對裡面帶有select option的操作。主要是想動態載入option和對option的選中。但是由於專案中使用了jquery裡的chosen()方法,怎麼也無法實現效果。原碼如下: Java程式碼   <select id="viewOLanguage" 

    Delegate 類 概念 與MVC模式不同model/view結構沒有用於與使用者互動的完全獨立的元件。一般來講 view負責把資料展示使用者也處理使用者的輸入。為了獲得更多的靈性性互動通過d

    Delegate  類 概念 與MVC模式不同,model/view結構沒有用於與使用者互動的完全獨立的元件。一般來講, view負責把資料展示給使用者,也處理使用者的輸入。為了獲得更多的靈性性,互動通過delegagte執行。它既提供輸入功能又負責渲染view中的每個