Skip to content

Commit

Permalink
fix: 增加参数noScroll控制grid不显示滚动条
Browse files Browse the repository at this point in the history
  • Loading branch information
yuekai liu committed Oct 20, 2016
1 parent d77b0c2 commit a20304f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
29 changes: 21 additions & 8 deletions dist/js/u-grid.js
Expand Up @@ -1750,7 +1750,7 @@
* 创建header区域table
*/
var createHeaderTable = function createHeaderTable(createFlag) {
var leftW, positionStr, idStr;
var leftW, positionStr, idStr, noScrollStr;
if (createFlag == 'fixed') {
leftW = parseInt(this.leftW);
positionStr = 'absolute;width:' + this.fixedWidth + 'px;z-index:11;background:#F9F9F9;';
Expand All @@ -1763,7 +1763,10 @@
positionStr += 'width:' + this.contentMinWidth + 'px;';
}
}
var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px">';
if (this.options.noScroll) {
noScrollStr = 'table-layout:auto;';
}
var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px;' + noScrollStr + '">';
htmlStr += this.createColgroup(createFlag);
htmlStr += '<thead role="rowgroup" id="' + this.options.id + '_header_' + idStr + 'thead">';
htmlStr += this.createThead(createFlag);
Expand Down Expand Up @@ -1967,12 +1970,15 @@
* 创建内容区table
*/
var createContentTable = function createContentTable(createFlag) {
var leftW, idStr, styleStr, hStr, cssStr, tableStyleStr;
var leftW, idStr, styleStr, hStr, cssStr, tableStyleStr, noScrollStr;
if (this.countContentHeight && parseInt(this.contentHeight) > 0) {
hStr = 'height:' + this.contentHeight + 'px;';
} else {
hStr = "";
}
if (this.options.noScroll) {
noScrollStr = 'table-layout:auto;';
}
if (createFlag == 'fixed') {
leftW = parseInt(this.leftW);
idStr = 'fixed_';
Expand All @@ -1990,13 +1996,14 @@
styleStr += '"';
tableStyleStr = '';
if (this.contentMinWidth > 0) {
if (this.contentWidth > 0) {
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;width:' + this.contentWidth + 'px;"';
} else {
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;"';
}
/*if(this.contentWidth > 0){ //后续待确定
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;width:' + this.contentWidth + 'px;' + noScrollStr + '"';
}else{*/
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;' + noScrollStr + '"';
/*}*/
}
}

var htmlStr = '<div id="' + this.options.id + '_content_' + idStr + 'div" class="u-grid-content-' + cssStr + 'div" ' + styleStr + '>';
htmlStr += '<div style="height:30px;position:absolute;top:-30px;width:100%;"></div><table role="grid" id="' + this.options.id + '_content_' + idStr + 'table" ' + tableStyleStr + '>';
htmlStr += this.createColgroup(createFlag);
Expand Down Expand Up @@ -2674,6 +2681,7 @@
this.options.autoExpand = this.getBoolean(this.options.autoExpand);
this.options.needTreeSort = this.getBoolean(this.options.needTreeSort);
this.options.needLocalStorage = this.getBoolean(this.options.needLocalStorage);
this.options.noScroll = this.getBoolean(this.options.noScroll);
};
/*
* 初始化默认参数
Expand Down Expand Up @@ -2764,6 +2772,11 @@
url = url.substring(0, index);
}
this.localStorageId = this.options.id + url;
if (this.options.noScroll) {
this.options.canSwap = false;
this.options.canDrag = false;
this.options.columnMenu = false;
}
};
var initOptionsTree = function initOptionsTree() {};
/*
Expand Down
6 changes: 3 additions & 3 deletions dist/js/u-grid.min.js

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions js/gridCompCreate.js
Expand Up @@ -119,7 +119,7 @@ const createHeader = function() {
* 创建header区域table
*/
const createHeaderTable = function(createFlag){
var leftW,positionStr,idStr;
var leftW,positionStr,idStr,noScrollStr;
if(createFlag == 'fixed'){
leftW = parseInt(this.leftW);
positionStr = 'absolute;width:'+this.fixedWidth+'px;z-index:11;background:#F9F9F9;';
Expand All @@ -132,7 +132,10 @@ const createHeaderTable = function(createFlag){
positionStr += 'width:'+this.contentMinWidth+'px;';
}
}
var htmlStr = '<table role="grid" id="' + this.options.id + '_header_'+idStr+'table" style="position:'+ positionStr+';left:' + leftW + 'px">';
if(this.options.noScroll){
noScrollStr = 'table-layout:auto;';
}
var htmlStr = '<table role="grid" id="' + this.options.id + '_header_'+idStr+'table" style="position:'+ positionStr+';left:' + leftW + 'px;' + noScrollStr + '">';
htmlStr += this.createColgroup(createFlag);
htmlStr += '<thead role="rowgroup" id="' + this.options.id + '_header_'+idStr+'thead">';
htmlStr += this.createThead(createFlag);
Expand Down Expand Up @@ -326,12 +329,15 @@ const createContentLeftNumColRow = function(index){
* 创建内容区table
*/
const createContentTable = function(createFlag){
var leftW,idStr,styleStr,hStr,cssStr,tableStyleStr;
var leftW,idStr,styleStr,hStr,cssStr,tableStyleStr,noScrollStr;
if(this.countContentHeight && parseInt(this.contentHeight) > 0){
hStr = 'height:' + this.contentHeight + 'px;';
}else{
hStr = "";
}
if(this.options.noScroll){
noScrollStr = 'table-layout:auto;';
}
if(createFlag == 'fixed'){
leftW = parseInt(this.leftW);
idStr = 'fixed_';
Expand All @@ -349,13 +355,14 @@ const createContentTable = function(createFlag){
styleStr += '"';
tableStyleStr = '';
if(this.contentMinWidth > 0){
if(this.contentWidth > 0){
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;width:' + this.contentWidth + 'px;"';
}else{
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;"';
}
/*if(this.contentWidth > 0){ //后续待确定
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;width:' + this.contentWidth + 'px;' + noScrollStr + '"';
}else{*/
tableStyleStr = 'style="min-width:' + this.contentMinWidth + 'px;' + noScrollStr + '"';
/*}*/
}
}

var htmlStr = '<div id="' + this.options.id + '_content_'+idStr+'div" class="u-grid-content-'+cssStr+'div" '+styleStr+'>';
htmlStr += '<div style="height:30px;position:absolute;top:-30px;width:100%;"></div><table role="grid" id="' + this.options.id + '_content_'+idStr+'table" ' + tableStyleStr+'>';
htmlStr += this.createColgroup(createFlag);
Expand Down
6 changes: 6 additions & 0 deletions js/gridCompInit.js
Expand Up @@ -55,6 +55,7 @@ const getBooleanOptions = function(){
this.options.autoExpand = this.getBoolean(this.options.autoExpand);
this.options.needTreeSort = this.getBoolean(this.options.needTreeSort);
this.options.needLocalStorage = this.getBoolean(this.options.needLocalStorage);
this.options.noScroll = this.getBoolean(this.options.noScroll);
};
/*
* 初始化默认参数
Expand Down Expand Up @@ -144,6 +145,11 @@ const initOptions = function() {
url = url.substring(0,index);
}
this.localStorageId = this.options.id + url;
if(this.options.noScroll){
this.options.canSwap = false;
this.options.canDrag = false;
this.options.columnMenu = false;
}

};
const initOptionsTree = function(){
Expand Down

0 comments on commit a20304f

Please sign in to comment.