| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <%@ page contentType="text/html;charset=GBK"%>
- <% String a="hi";%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=GBK">
- <title>Paging Grid Example</title>
- <link rel="stylesheet" type="text/css" href="/shares/js/ext/resources/css/ext-all.css"/>
- <!-- GC -->
- <!-- LIBS -->
- <script type="text/javascript" src="/ynet/js/ext/adapter/ext/ext-base.js"></script>
- <!-- ENDLIBS -->
- <script type="text/javascript" src="/ynet/js/ext/ext-all.js"></script>
- <script type="text/javascript" src="/ynet/js/ext/ux/SearchField.js"></script>
- <script type="text/javascript">
- function edit(id){}
- /*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
- Ext.onReady(function(){
- Ext.QuickTips.init();
- // create the Data Store
- var store = new Ext.data.JsonStore({
- root: 'data',
- totalProperty: 'totalCount',
- remoteSort: true,
- fields:<%=request.getAttribute("fields")%>,
- // load using script tags for cross domain, if the data in on the same domain as
- // this page, an HttpProxy would be better
- proxy: new Ext.data.HttpProxy({
- url: '/ynet/ExtPagingImpl.do?v=<%=request.getParameter("v")%>'
- }),
- baseParams: {limit:20, forumId: 4}
- });
-
- // pluggable renders
- function renderCommand(value, p, record){
- var edit="<a href=<%=request.getContextPath()%>/<%=request.getAttribute("edit")%>?id="+record.data.universalid+">修改</a>";
- var see=" <a href=<%=request.getContextPath()%>/<%=request.getAttribute("see")%>?id="+record.data.universalid+">查看</a>";
- return (edit+see);
- }
- function renderCommand1(value, p, record){
- var edit="<%=request.getContextPath()%>/<%=request.getAttribute("edit")%>?id="+record.data.universalid;
- var id=record.get('universalid');
- return String.format("<a href=# onclick=edit('{0}')>浏览</a>",record.data.universalid);
- }
- function renderCommand2(edit){
- var editWindow = new Ext.Window({
- title: '查看记录',
- width: 800,
- height:600,
- collapsible:true,
- maximizable:true,
- layout: 'fit',
- plain:true,
- bodyStyle:'padding:5px;',
- modal:true,
- html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src='+edit+'></iframe>'
- });
- editWindow.show();
- }
- var sm = new Ext.grid.CheckboxSelectionModel();
- function hi(action){
- var records =grid.getSelectionModel().getSelections();
- if (records.length==0){
- Ext.Msg.alert('操作提示','没有选择');
- return;
- }
- var ids=[];
- for (var i = 0, len = records.length; i < len; i++) {
- ids[i]=records[i].data.universalid;
- }
- Ext.Ajax.request({
- url:action,
- method:'post',
- params:{ids:ids},
- success: function(arg) {
- var jsonResult = Ext.util.JSON.decode(arg.responseText);
- if (jsonResult[0].sucess=='ok'){
- Ext.Msg.alert('操作提示', jsonResult[0].info);
- }
- else{
- Ext.Msg.alert('操作提示',jsonResult[0].info);
- }
- },
- failure: function(response) {
- //var respText = Ext.util.JSON.decode(resp.responseText);
- Ext.Msg.alert('操作失败', 'hi');
- }
- });
- //grid.store.reload();
- }
- var grid = new Ext.grid.GridPanel({
- //layout:'fit',
- height:Ext.getBody().getViewSize().height,
- title:'列表',
- store: store,
- trackMouseOver:false,
- disableSelection:true,
- loadMask: true,
- // 列数据,从服务器生成
- columns:<%=request.getAttribute("columns")%>,
- sm:sm,
- //工具条,以下从服务器生成
- tbar:[<%=request.getAttribute("toolButtons")%>,
- 'Search: ', ' ',
- new Ext.ux.form.SearchField({
- store: store,
- width:320
- })
- ],
- // paging bar on the bottom
- bbar: new Ext.PagingToolbar({
- pageSize: 20,
- store: store,
- beforePageText:"当前第",
- afterPageText:"页,共{0}页",
- lastText:"尾页",
- nextText :"下一页",
- prevText :"上一页",
- firstText :"首页",
- refreshText:"刷新页面",
- displayInfo: true,
- displayMsg:"当前显示 {0} - {1}条, 共 {2}",
- emptyMsg: "没有记录"
- })
- });
- grid.addListener('cellclick',function(grid, rowIndex,columnIndex,e){
- //alert(columnIndex);
- var record = grid.getStore().getAt(rowIndex).data;
- var edit="<%=request.getContextPath()%>/<%=request.getAttribute("edit")%>?id="+record.universalid;
- //renderCommand2(edit);
- if(columnIndex == 1){
- var record = grid.getStore().getAt(rowIndex).data;
- //alert(columnIndex);
- }
- });
- // render it
- grid.render('grid');
- // trigger the data store load
- store.load({params:{start:0, limit:20}});
- });
-
- </script>
- <link rel="stylesheet" type="text/css" href="grid-examples.css" />
- <!-- Common Styles for the examples -->
- </head>
- <body height="100%">
- <div id="grid"></div>
- </body>
- </html>
|