页面在初始化加载数据较多时会非常耗时,如果只加载表格,用户再根据自己的需要通过条件查询数据,就会节约一些时间,提高用户体验,所以在初始化datagrid时想只加载表格不加载数据,做到数据与表格加载分离的效果。
经过实验发现,使用.datagrid()方法时,参数中只要有URL存在,都会自动调用一次加载数据,可设置url参数为null,则加载表格时就不会向后台发出请求;但是此时如果用户想重置页面条件,重新加载页面时,由于没有请求后台,只加载表格,则会发生页面条件清空,表格数据还在或者表格数据为空分页展示的记录却不为0的现象,所以也需要重置数据和分页参数,具体代码如下:
[javascript] view plain copy
/**
* dataGrid初始化表格
* @param id datagrid的id
* @param column 展示的列名
* @param opt 设置自定义datagrid属性
*/
function commonInitDataGrid(id, column, opt){
var initData =
{
"code":100,
"msg":"",
"data":{"totalDataCount":0,"totalPageCount":0,"list":[],"properties":{"footer": []}}
}
//校验参数
if(isEmpty(id) || isEmpty(column)){
jQuery.messager.alert("系统提示", "系统错误,请联系技术人员!")
return
}
//默认属性
var defaultOpt= {
"url": null,
"method": 'POST', //请求方式
"columns": column,
"width": document.body.clientWidth < 756 ? 756 - 18 : document.body.clientWidth - 18,
"remoteSort": false,
"rownumbers": true,
"pagination": true,
"showFooter": true,
"fitColumns": true,
"pageNumber": 1,
"pageSize": 20,
"pageList": [10, 20, 30, 50, 100],
"singleSelect": true,
"striped": true,
"loadFilter": function (result) {
if (result.code == "100") {
//解析json结果集,返回给datagrid
var obj =
{
"total": result.data.totalDataCount,
"rows": result.data.list,
"footer": result.data.properties.footer
}
return obj
} else {
jQuery.messager.alert("系统提示", result.msg)
return false
}
}
}
if(!isEmpty(opt)){
//替换自定义属性
$.extend(defaultOpt, opt)
}
//把属性与事件放到表格中,进行初始化
$("#" + id).datagrid(defaultOpt)
$("#" + id).datagrid('loadData', initData)
}
说明:1.设置URL为null后,则每次调用此方法都只会加载表格,不加载数据,调用此方法时就不需要再调用此方法之前设置URL了;
2.pageSize的参数不在pageList之中时,页面分页会默认取pageList中的第一个参数,此时pageSize设置无效。
3.loadFilter方法是为了处理后台返回的结果,并自动传给datagrid进行处理然后展示在页面
如果要达到这个功能呢,必须学几个部分:1):是html语言,至少得学会select怎么编。。<select id="lists"><option value="?">?</option></select>
2):数据库语言,你得能够查询数据库,从数据库中选出与你内容相近的东东
3):脚本语言(script)
4):ajax 时时通信脚本
学会了这几个呢,基本上,其它的都不是问题了!
HTML5手机上下滑动翻页特效是一款手机移动端触屏滑动效果实现完整代码如下:
1、html5页面代码
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8">
<title>HTML5手机页面触屏滑动上下翻页特效</title>
<meta charset="utf-8">
<meta name="apple-touch-fullscreen" content="YES">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="pragram" content="no-cache">
<link rel="stylesheet" type="text/css" href="./hamer_files/main.css">
<link rel="stylesheet" type="text/css" href="./hamer_files/endpic.css">
<script type="text/javascript" src="./hamer_files/offline.js"></script>
<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">
</head>
<body class="s-bg-ddd pc no-3d perspective yes-3d" style="-webkit-user-select: none">
<section class="u-alert">
<img style="display:none" src="./hamer_files/loading_large.gif">
<div class="alert-loading z-move">
<div class="cycleWrap"> <span class="cycle cycle-1"></span>
<span class="cycle cycle-2"></span><span class="cycle cycle-3"></span><span class="cycle cycle-4"></span>
</div>
<div class="lineWrap"> <span class="line line-1"></span><span class="line line-2"></span><span class="line line-3"></span>
</div>
</div>
</section>
<section class="u-arrow">
<p class="css_sprite01"></p>
</section>
<section class="p-ct transformNode-2d transformNode-3d" style="height: 918px">
<div class="translate-back" style="height: 918px">
<div class="m-page m-fengye" data-page-type="info_pic3" data-statics="info_pic3" style="height: 918px">
<div class="page-con lazy-finish" data-position="50% 50%" data-size="cover" style="height: 920pxbackground-image: url(hamer_files/1.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/2.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/3.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/4.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/5.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/6.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/7.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
<div class="m-page m-bigTxt f-hide" data-page-type="bigTxt" data-statics="info_list" style="height: 918px">
<div class="page-con j-txtWrap lazy-finish" data-position="50% 50%" data-size="cover" style="background-image: url(hamer_files/8.jpg)background-size: coverbackground-position: 50% 50%"></div>
</div>
</div>
</section>
<section class="u-pageLoading">
<img src="./hamer_files/load.gif" alt="loading">
</section>
<script src="./hamer_files/init.mix.js" type="text/javascript" charset="utf-8"></script>
<script src="./hamer_files/coffee.js" type="text/javascript" charset="utf-8"></script>
<script src="./hamer_files/99_main.js" type="text/javascript" charset="utf-8"></script>
</body></html>
2、css代码:
@charset "utf-8"
.ad_foot li { margin:0 auto 1emfont-size:1.8empadding:15pxbackground:#FFF}
.ad_foot li a {display:block}
.ad_foot li .l {width:75pxheight:75pxfloat:leftoverflow:hidden}
.ad_foot li .l img {width:75pxwidth:75px}
.ad_foot li .r {width:78%float:leftmargin-left:30pxcolor:#666overflow:hidden}
.ad_foot li .r p {color:#999font-size:1.2em}
.ad_foot li .r span {font-size:0.8em}
.ad_foot li .r i {font-style:normal}
.lazy-img, .lazy-finish{background-color:#f0eded}
.page-list{font-size:20pxfont-family: "Microsoft yahei"padding-left:17pxpadding-top:30pxheight:35pxborder-bottom:1px solid #b5b5b5display:none}
.ad_foot{padding:15px 15px 0 15px}
/*声音播放按钮*/
#song_img {width:293pxheight:41pxdisplay:blockposition:absoluteright:4.1emtop:1.6emfont-size:1.7emtext-align:centerline-height:41pxcolor:#FFFbackground:url(../img/music_c3.png) no-repeat 0 0}
/*底部推荐*/
.ad_list{margin-top:2em}.ad_list li {width:46%background:nonepadding:0float:leftmargin-bottom: 1em}
.ad_list li.r {float:right}.ad_list li a img {width:100%height:auto}
.ad_foot h3 {width:100%height:48pxline-height:48pxbackground:#F9F5EC}
.ad_foot h3 a {display:inline-blockcolor:#444width:50%text-align:centerfont-size:1.5emheight:48pxborder-bottom:2px solid #FF9240}
.ad_foot h3 a.active {color:#FFFbackground:#FF9240}
.magazine_1 li {
width:100%
margin-bottom: 1em
font-size: 1.8em
padding: 15px
background: #FFF}
.magazine_1 li a {display:block}
.magazine_1 li .l {width: 75px
height: 75px
float: left
overflow: hidden}
.magazine_1 li .l img {width:75pxheight:75px}
.magazine_1 li .r {width: 78%
float: left
margin-left: 30px
color: #666
overflow: hidden}
.magazine_1 li .r p {
color: #999
font-size: 1.2em
.magazine_1 li .r span {font-size:0.8em}
.ad_foot li .r i {font-style:normal}
3、运行效果如下:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)