zoukankan      html  css  js  c++  java
  • jqGrid使用

    基本配置

    "GRID_OPTION" : function(){
    		return {
    			"shrinkToFit" : true,
    			"gridstate" : "hidden",
    			"height" : "auto",
    		    "rowNum": 10,
    		    "rowList": [10, 20, 30],
    			"viewrecords": true,
    		    "gridview": true,
    		    "pager" : "#grid-pager",
    		    "autowidth" : true,
    		    "toolbar" : [true,'bottom'],
    		    "jqModal" : false,
    		    "datatype" : "json",
    		    "mtype" : "POST",
    			"jsonReader" : { 
    	            root:"data.pageData",
    	            page: "data.pagecurrentPage",
    	            total: "data.totalPage",
    	            records: "data.totalRows",
    	            repeatitems : false
    	        },
    		    "loadComplete":function(){	            
    		    	$('.navtable .ui-pg-button').tooltip({container:'body'});
    				$(this).find('.ui-pg-div').tooltip({container:'body'});
    		    }
    		};
    	}
    };
    

      

    $grid =$grid.jqGrid($.extend(Const.GRID_OPTION(),{
    			'url' : PATH+'/treatment/phr/basicInfo/page',
    			'colNames':['id','操作'],
    			'colModel':[
    			    {'name':'id', 'hidden':true},  {'name':'option','fixed':true,'sortable':false,'resize':false,'formatter':rowformatter,'width':100}
                ],
                'caption' : '列表'
    		})).jqGrid('navGrid',Const.GRID_PAGER_ID,{
    			edit: false,
    			add: true,
    			addicon : 'ace-icon fa fa-plus-circle purple',
    			
    			addfunc : function(e){
    				$formDialog.dialog($.extend(dialogOption,{title:"新增"}));
    				$formDialog.dialog("open");
    				reloadHisGrid();
    			},
    			
    			del: false,
    			search: false,
    			refresh: true,
    			refreshicon : 'ace-icon fa fa-refresh green'
    		});
    

      其中操作配置为:

    var rowformatter = function(cellvalue, options, rowObject){
    			rowObject.rowId = options.rowId;
    			return Const.OPT_TPL(rowObject);
    		};
    

      

    "OPT_TPL" : _.template($.trim($("#operation-formmatter-tpl").html()),{ 'variable': 'row' }),
    

      

    操作显示:

    <script id="operation-formmatter-tpl" type="lodash-tpl">
    	<div style="margin-left:8px;"><div title="查看所选记录" data-rowid={{=row.rowId}}  data-objId="{{=row.id}}" onclick="jQuery.fn.detailById.call(this)" style="float:left;cursor:pointer;" class="ui-pg-div ui-inline-detail"><span class="ui-icon ui-icon-search"></span></div></div>
    </script>	
    

      

    获取选中行数据:

    var obj = $grid.getRowData($(this).attr("data-rowid"));
    

      

    重新加载表单数据:

    $grid.jqGrid('setGridParam',{
    					page : 1,
    					postData : {}
    				}).trigger('reloadGrid');
    

      

  • 相关阅读:
    oracle热备份与冷备份的对比
    oracle数据库备份
    shell 去除空行
    已有实例 Oracle 下新增实例(2)通过dbca克隆实例
    oracle启动,提示“LRM-00109: could not open parameter file”
    linux——使用fidsk对linux硬盘进行操作【转】
    前端——知识点
    hdu 3996 Gold Mine 最大权闭合子图
    hdu 3917 Road constructions 最大权闭合子图
    poj 2987 Firing 最大权闭合子图
  • 原文地址:https://www.cnblogs.com/binbang/p/4772595.html
Copyright © 2011-2022 走看看