Permalink
Browse files

fix: 增加参数noScroll控制grid不显示滚动条

  • Loading branch information...
yuekai liu
yuekai liu committed Oct 20, 2016
1 parent d77b0c2 commit a20304f297a84732cdbd5e0edf8a618fa4c7f7be
Showing with 45 additions and 19 deletions.
  1. +21 −8 dist/js/u-grid.js
  2. +3 −3 dist/js/u-grid.min.js
  3. +15 −8 js/gridCompCreate.js
  4. +6 −0 js/gridCompInit.js
View
@@ -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;';
@@ -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);
@@ -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_';
@@ -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);
@@ -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);
};
/*
* 初始化默认参数
@@ -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() {};
/*
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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;';
@@ -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);
@@ -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_';
@@ -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);
View
@@ -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);
};
/*
* 初始化默认参数
@@ -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(){

0 comments on commit a20304f

Please sign in to comment.