标签:
1. 初始化的时候不加载数据设置datatype: ‘local‘
1 $("#grid").jqGrid({
2 url:"http://www.8qiu.cn",
3 datatype:"local",
4 //other options
5 });
2. 当要加载数据的时候把datatype改成json或者XML:
$("#list").jqGrid(‘setGridParam‘,{datatype:‘json‘}).trigger(‘reloadGrid‘);
3.如果不要jqgrid表头上的点击排序可以把对应的colModel中加属性sortable : false.
4.如果要想显示jqgrid中的caption可以在css样式中加入如下(你可以发现.ui-jqgrid .ui-jqgrid-titlebar 的div块display是none,所以没显示)
1 .ui-jqgrid .ui-jqgrid-titlebar
2 {
3 display:block;
4 }
5.如果要使用jqgrid中caption中文字居中显示
1 gridComplete: function(){
2 $(‘#list‘).closest("div.ui-jqgrid-view")
3 .children("div.ui-jqgrid-titlebar")
4 .css("text-align", "center")
5 .children("span.ui-jqgrid-title")
6 .css("float", "none");
7 }
6.当浏览器的大小改变时,jqgrid的宽度作为相应的改变
1 gridComplete: function(){
2 $(window).resize(function(){
3 var winwidth=$(window).width()*0.5; //这里的0.5可以自己定
4 $("#list").setGridWidth(winwidth);
5 });
6
7 }
7.jqgrid关于日期格式化在colModel中添加
1 formatter:‘date‘,
2 formatoptions:{srcformat:‘Y-m-d H:i‘,newformat:‘Y-m-d‘}
标签:
原文地址:http://www.cnblogs.com/wushuishui/p/4350937.html