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');
    

      

  • 相关阅读:
    Shell编程进阶 1.2 shell结构及执行
    LNMP 1.6 常见的502问题解决
    关于贴图看不到。显示是白色或者其他。
    windows 任务栏图标宽度固定
    Install Oracle Java JDK/JRE 7u55 on Fedora 20/19, CentOS/RHEL 6.5/5.10
    盘点天龙历史:七年以来所有资料片
    linux shell 逻辑运算符、逻辑表达式详解
    vim 把满足条件的数字进行加上一些数字
    win7 一些快捷系统工具命令
    Linux下用C读取配置文件。类似ini这样。
  • 原文地址:https://www.cnblogs.com/binbang/p/4772595.html
Copyright © 2011-2022 走看看