Authored by xuhongyun

支持页面刷新后,选中的页面条数不变

... ... @@ -30,6 +30,7 @@ var grid = function(options) {
var defaults = {
hash: true,
//size: 10,
size: 10,
innerHtml: "<div class='grid'><table class='table table-striped table-bordered responsive dataTable no-footer' role='grid' aria-describedby='basicTable_info'>" + "<thead></thead><tbody></tbody></table></div>" +
"<div class='t_foot'><ul class='pagination' style='float: left; margin: 10px 0'></ul><select class='form-control t_size' style='display:none; width: 80px; height: 32px; padding: 0 10px; float: left; margin: 10px 0 10px 10px'>" +select.join('') +
"</select><span class='label label-info t_total' style='display:none; width: 80px; height: 32px; float: left; padding: 10px; margin: 10px 0 10px 10px'></span></div>",
... ... @@ -479,6 +480,16 @@ grid.prototype = {
$(g.grid).on("change",".t_size",function(){
p.size=$(this).val();
// 将当前页面size保存起来
if (location.hash.search(/size=(\d+)/g) > -1) {
location.hash = location.hash.replace(/size=(\d+)/g, function(source, $1) {
return "size=" + p.size;
})
} else {
location.hash += "&size=" + p.size;
}
g.reload(1);
})
}
... ...
... ... @@ -115,25 +115,29 @@ toast.prototype.tabTreeHelper = function (tabTree, sort) {
* @returns {number}
*/
toast.prototype.pageHelper = function () {
var url = window.location.href.split('?')[0];
var params = url.split('#');
if (params.length <= 1) {
return 1;
}
var page = 1;
$.each(params, function (index) {
var param_split = params[index].split('=');
if (param_split.length > 1 && param_split[0].toLowerCase() == "page") {
page = Number.parseInt(param_split[1]);
return false;
}
})
if (location.hash.search(/page=(\d+)/g) > -1) {
page = /page=(\d+)/g.exec(location.hash)[1];
}
return page;
}
/**
* 获取url上配置的pageSize参数,如果没有则返回1
* pageSize 平台端全部默认10条
* @returns {number}
*/
toast.prototype.pageSizeHelper = function (g) {
var pageSize = 10;
if (location.hash.search(/size=(\d+)/g) > -1) {
pageSize = /size=(\d+)/g.exec(location.hash)[1];
}
return pageSize;
}
/**
* 获取url上的查询串,通过数据返回
* @returns 包含所有查询参数的对象,可以通过returnValue["xxx"]方式获取
*/
... ...
... ... @@ -143,6 +143,7 @@ var g = new common.grid({
el: "#basicTable",
usepagesize:true,
page: refreshHelper.pageHelper(),
size: refreshHelper.pageSizeHelper(g),
parms: function () {
return {
productSkn: refreshHelper.inputHelper("productSkn"),
... ...