点击grid单元格弹出新窗口

实现功能:点击指定单元格后会弹出新窗口,并且最后一行合计不会触发单元格触发函数 

 1     <script type="text/javascript">
 2         grid.on('cellclick',function(grid, rowIndex, columnIndex, e){
 3                 var selections = grid.getSelectionModel().getSelections();//获取行
 4                 var record = grid.getStore().getAt(rowIndex);  //Get the Record
 5                 var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //获取字段名称
 6                 var nbbm = record.get("Id");//获取字段id的值
 7                 if(rowIndex < selections.length){//当前行数不是最后一行时
 8                     if(fieldName=='m'){//当字段名为m的单元格点击触发
 9                         var newStore = new Ext.data.Store({
10                                 autoLoad :{params : {start:0,limit :10,id:id}},
11                                 reader: new Ext.data.JsonReader(
12                                     {             
13                                        totalProperty: "total",
14                                        root: "data"
15                                     },
16                                     Ext.data.Record.create([
17                                         {name:"id"},
18                                         {name:"num"},
19                                         {name:"mxbm"},
20                                     {name:"time"}])),
21                                 proxy : new Ext.data.HttpProxy({
22                                        url:"/servlet?action=m&id="+id
23                                 })
24                         });
25                         var newGrid=new Ext.grid.GridPanel({
26                             viewConfig:{forceFit:true,autoScroll:true},
27                             store:newStore,
28                             height:300,
29                             bodyStyle:'width:100%',
30                             layout:"table",
31                             border:"1",
32                             columns:[
33                                 {header:"ID", dataIndex:"cashNBBM",hidden:true}, 
34                                 {header:"序号",dataIndex:"num"}, 
35                                 {header:"编码",dataIndex:"mxbm"},
36                                 {header:"日期",dataIndex:"time"}],
37                             bbar:new Ext.PagingToolbar({
38                                  emptyMsg:"没有数据",
39                                  displayInfo:true,
40                                  displayMsg:"目前显示第 {0} - {1} 条,共 {2} 条",
41                                  store:newStore,
42                                  pageSize:10,
43                                  refreshText:"刷新列表"
44                              })
45                         });
46                         var newWin = new Ext.Window({
47                             title:"新窗口",
48                             //el:'window-win',
49                             layout:'fit',
50                             width:800,
51                             height:400,
52                             items: [newGrid]
53                         }); 
54                         newWin.show(); 
55                     }
56                }
57           }
58     </script>
点击单元格触发

 

 

posted @ 2013-08-10 16:03  爱笑的狐狸  阅读(673)  评论(0编辑  收藏  举报