欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

EXT_grid_rowclick_jsonStore EXTJSP框架HTML 

程序员文章站 2022-04-03 10:01:18
...
<html>
<head>
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all-debug.js"></script>
<script>
function fn()
{
	//Ext.BLANK_IMAGE_URL ="/resource/extjs31/resources/images/default/tree/s.gif";
	
   var data={totalCount:0,data:[{ID:'1',TITLE:'HAO',PUBTIME:'2009'},{ID:'33',TITLE:'3333',PUBTIME:'23333'}]};
	var urlstr='/fbrole/main/itsmIndexGetInfoData.jsp?ch_id='+"<%=ch_id%>";
	//数据部分
	 var store=new Ext.data.JsonStore({
  				start:0,
  				limit:5,      
                root:"data",      
                totalProperty:"totalCount",
                idProperty:"ID",
                fields:["ID","TITLE","PROMULGATOR","PUBTIME"],
                proxy:new Ext.data.MemoryProxy(data)
                //proxy: new Ext.data.HttpProxy({	url:urlstr })
            });    

   //框架部分
   var mainPanel = new Ext.Panel({
       layout:'border',
       applyTo:document.body,
       width:1023,
       height:500,
       items:[
           new Ext.grid.GridPanel({
            id:'gridepanel',
		      title:"<%=ch_name%>",
		      region:'center',
		      frame:true,
		      store:store,
		      autoExpandColumn:2,
		      listeners:{
               rowclick : function(grid, rowIndex, e){
                  console.dir(e);
                  var selections = grid.getSelectionModel().getSelections();
                  if (selections.length == 0) { Ext.Msg.alert('提示', "先选择行"); return; }
                  for (var i = 0; i < selections.length; i++) {
                      var record = selections[i];
                      alert(record.get("ID"));
                      var id = record.get("ID");
                      var url = "panel.html";
                      window.open(url);
                  }
               }
            },
		      tbar : new Ext.PagingToolbar({
		         store:store,
		         pageSize:5,//每页显示几条记录
		         displayInfo:true,
		         displayMsg:'第{0}条到{1}条,一共{2}条',
		         emiptyMes:'没有记录'
		      }),
		      columns:[
		         new Ext.grid.RowNumberer(),
		         {header:"标题",width:300,dataIndex:"TITLE"},
		         {header:"发布时间",dataIndex:"PUBTIME"}
		      ]
		   })
	    ]
   });

   store.load({params:{start:0, limit:5}});

   var el = Ext.getCmp('gridepanel');
   //console.dir(el);
}
Ext.onReady(fn);

</script>
	
</head>
<body>
</body>
</html>