Permalink
Browse files

feat: grid增加参数fixedFloat可设置固定列在左侧还是右侧

  • Loading branch information...
LiuYueKai committed Feb 22, 2017
1 parent 71297ad commit 9c31d26f6402cdd9f9ac9dd98023f4c8d95b81f7
View
@@ -589,7 +589,11 @@
$('#' + this.options.id + '_content_div').on('scroll', function (e) {
oThis.scrollLeft = this.scrollLeft;
oThis.scrollTop = this.scrollTop;
- $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ if (oThis.options.fixedFloat == 'right') {
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + "px");
+ } else {
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ }
$('#' + oThis.options.id + '_noRowsShow').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_edit_form').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_content_multiSelect').css('top', -oThis.scrollTop + "px");
@@ -1872,14 +1876,22 @@
positionStr = 'absolute;width:' + this.fixedWidth + 'px;z-index:11;background:#F9F9F9;';
idStr = 'fixed_';
} else {
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ if (this.options.fixedFloat == 'right') {
+ leftW = parseInt(this.leftW);
+ } else {
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ }
positionStr = 'relative;';
idStr = '';
if (this.contentMinWidth > 0) {
positionStr += 'width:' + this.contentMinWidth + 'px;';
}
}
- var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px;">';
+ if (createFlag == 'fixed' && this.options.fixedFloat == 'right') {
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';right:0px;">';
+ } else {
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px;">';
+ }
htmlStr += this.createColgroup(createFlag);
htmlStr += '<thead role="rowgroup" id="' + this.options.id + '_header_' + idStr + 'thead">';
htmlStr += this.createThead(createFlag);
@@ -1963,7 +1975,8 @@
var createContent = function createContent() {
var h = '',
displayStr = '',
- bottonStr = '';
+ bottonStr = '',
+ lbw = 0;
if (this.countContentHeight) {
var wh = $('#' + this.options.id)[0].offsetHeight;
this.wholeHeight = wh;
@@ -1985,7 +1998,12 @@
if (u.isIOS) {
displayStr += 'width:0px;';
}
- htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + (this.leftW + this.fixedWidth) + 'px;' + displayStr + '">';
+ if (this.options.fixedFloat == 'right') {
+ lbw = this.leftW;
+ } else {
+ lbw = this.leftW + this.fixedWidth;
+ }
+ htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + lbw + 'px;' + displayStr + '">';
htmlStr += '</div>';
}
htmlStr += this.createContentTableFixed();
@@ -2098,10 +2116,18 @@
leftW = parseInt(this.leftW);
idStr = 'fixed_';
cssStr = 'fixed-';
- styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;left:' + leftW + 'px;' + hStr + '"';
+ if (this.options.fixedFloat == 'right') {
+ styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;right:0px;' + hStr + '"';
+ } else {
+ styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;left:' + leftW + 'px;' + hStr + '"';
+ }
tableStyleStr = 'style="width:' + this.fixedWidth + 'px;"';
} else {
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth, 0);
+ if (this.options.fixedFloat == 'right') {
+ leftW = parseInt(this.leftW);
+ } else {
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth, 0);
+ }
idStr = '';
cssStr = '';
styleStr = 'style="position:relative;left:' + leftW + 'px;' + hStr;
@@ -2844,7 +2870,9 @@
noScroll: false, // 是否显示滚动条,宽度设置百分比的话不显示滚动条
contentSelect: true, // 点击内容区是否执行选中逻辑
showEditIcon: false, // 是否显示编辑图标
- contentFocus: true };
+ contentFocus: true, // 点击内容区是否执行focus逻辑
+ fixedFloat: 'left'
+ };
};
/*
* 创建grid
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -137,14 +137,22 @@ var createHeaderTable = function createHeaderTable(createFlag) {
positionStr = 'absolute;width:' + this.fixedWidth + 'px;z-index:11;background:#F9F9F9;';
idStr = 'fixed_';
} else {
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ if (this.options.fixedFloat == 'right') {
+ leftW = parseInt(this.leftW);
+ } else {
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ }
positionStr = 'relative;';
idStr = '';
if (this.contentMinWidth > 0) {
positionStr += 'width:' + this.contentMinWidth + 'px;';
}
}
- var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px;">';
+ if (createFlag == 'fixed' && this.options.fixedFloat == 'right') {
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';right:0px;">';
+ } else {
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_' + idStr + 'table" style="position:' + positionStr + ';left:' + leftW + 'px;">';
+ }
htmlStr += this.createColgroup(createFlag);
htmlStr += '<thead role="rowgroup" id="' + this.options.id + '_header_' + idStr + 'thead">';
htmlStr += this.createThead(createFlag);
@@ -228,7 +236,8 @@ var createThead = function createThead(createFlag) {
var createContent = function createContent() {
var h = '',
displayStr = '',
- bottonStr = '';
+ bottonStr = '',
+ lbw = 0;
if (this.countContentHeight) {
var wh = $('#' + this.options.id)[0].offsetHeight;
this.wholeHeight = wh;
@@ -250,7 +259,12 @@ var createContent = function createContent() {
if (u.isIOS) {
displayStr += 'width:0px;';
}
- htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + (this.leftW + this.fixedWidth) + 'px;' + displayStr + '">';
+ if (this.options.fixedFloat == 'right') {
+ lbw = this.leftW;
+ } else {
+ lbw = this.leftW + this.fixedWidth;
+ }
+ htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + lbw + 'px;' + displayStr + '">';
htmlStr += '</div>';
}
htmlStr += this.createContentTableFixed();
@@ -363,10 +377,18 @@ var createContentTable = function createContentTable(createFlag) {
leftW = parseInt(this.leftW);
idStr = 'fixed_';
cssStr = 'fixed-';
- styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;left:' + leftW + 'px;' + hStr + '"';
+ if (this.options.fixedFloat == 'right') {
+ styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;right:0px;' + hStr + '"';
+ } else {
+ styleStr = 'style="position:absolute;width:' + this.fixedWidth + 'px;left:' + leftW + 'px;' + hStr + '"';
+ }
tableStyleStr = 'style="width:' + this.fixedWidth + 'px;"';
} else {
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth, 0);
+ if (this.options.fixedFloat == 'right') {
+ leftW = parseInt(this.leftW);
+ } else {
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth, 0);
+ }
idStr = '';
cssStr = '';
styleStr = 'style="position:relative;left:' + leftW + 'px;' + hStr;
View
@@ -62,7 +62,11 @@ var initContentDivEventFun = function initContentDivEventFun() {
$('#' + this.options.id + '_content_div').on('scroll', function (e) {
oThis.scrollLeft = this.scrollLeft;
oThis.scrollTop = this.scrollTop;
- $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ if (oThis.options.fixedFloat == 'right') {
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + "px");
+ } else {
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ }
$('#' + oThis.options.id + '_noRowsShow').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_edit_form').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_content_multiSelect').css('top', -oThis.scrollTop + "px");
View
@@ -99,7 +99,9 @@ var initDefault = function initDefault() {
noScroll: false, // 是否显示滚动条,宽度设置百分比的话不显示滚动条
contentSelect: true, // 点击内容区是否执行选中逻辑
showEditIcon: false, // 是否显示编辑图标
- contentFocus: true };
+ contentFocus: true, // 点击内容区是否执行focus逻辑
+ fixedFloat: 'left'
+ };
};
/*
* 创建grid
View
@@ -1,6 +1,6 @@
{
"name": "tinper-neoui-grid",
- "version": "3.1.26",
+ "version": "3.1.27",
"description": "grid",
"main": "gulpfile.js",
"directories": {
View
@@ -129,14 +129,22 @@ const createHeaderTable = function(createFlag){
positionStr = 'absolute;width:'+this.fixedWidth+'px;z-index:11;background:#F9F9F9;';
idStr = 'fixed_';
}else{
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ if(this.options.fixedFloat == 'right'){
+ leftW = parseInt(this.leftW);
+ }else{
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth);
+ }
positionStr = 'relative;';
idStr = '';
if(this.contentMinWidth > 0){
positionStr += 'width:'+this.contentMinWidth+'px;';
}
}
- var htmlStr = '<table role="grid" id="' + this.options.id + '_header_'+idStr+'table" style="position:'+ positionStr+';left:' + leftW + 'px;">';
+ if(createFlag == 'fixed' && this.options.fixedFloat == 'right'){
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_'+idStr+'table" style="position:'+ positionStr+';right:0px;">';
+ }else{
+ var htmlStr = '<table role="grid" id="' + this.options.id + '_header_'+idStr+'table" style="position:'+ positionStr+';left:' + leftW + 'px;">';
+ }
htmlStr += this.createColgroup(createFlag);
htmlStr += '<thead role="rowgroup" id="' + this.options.id + '_header_'+idStr+'thead">';
htmlStr += this.createThead(createFlag);
@@ -212,7 +220,7 @@ const createThead = function(createFlag) {
* 创建内容区域
*/
const createContent = function() {
- var h = '',displayStr = '',bottonStr='';
+ var h = '',displayStr = '',bottonStr='',lbw = 0;
if(this.countContentHeight){
var wh = $('#' + this.options.id)[0].offsetHeight;
this.wholeHeight = wh;
@@ -234,7 +242,12 @@ const createContent = function() {
if(u.isIOS){
displayStr += 'width:0px;';
}
- htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + (this.leftW + this.fixedWidth) + 'px;'+displayStr+'">';
+ if(this.options.fixedFloat == 'right'){
+ lbw = this.leftW;
+ }else{
+ lbw = this.leftW + this.fixedWidth;
+ }
+ htmlStr += '<div class="u-grid-content-left-bottom" id="' + this.options.id + '_content_left_bottom" style="width:' + lbw + 'px;'+displayStr+'">';
htmlStr += '</div>';
}
htmlStr += this.createContentTableFixed();
@@ -297,7 +310,7 @@ const createContentLeftMultiSelectRow = function(row,displayFlag){
var rootObj = row.value;
var objAry = this.selectRows;
- var re = objCompare(rootObj, objAry);
+ var re = objCompare(rootObj, objAry);
if(gridBrowser.isIE8){
//var htmlStr = '<div style="width:' + this.multiSelectWidth + 'px;' + displayStr + '" class="u-grid-content-multiSelect " ><input class="u-grid-multi-input" id="checkbox'+tmpcheck+'" type="checkbox" value="1" ></div>'
@@ -319,13 +332,13 @@ const createContentLeftNumColRow = function(index){
var row = this.dataSourceObj.rows[index];
var rootObj = row.value;
var objAry = this.selectRows;
- var re = objCompare(rootObj, objAry);
+ var re = objCompare(rootObj, objAry);
var htmlStr;
if(re){
htmlStr = '<div style="width:' + this.numWidth + 'px;" class="u-grid-content-num u-grid-content-sel-row">' + (index+1) + '</div>';
}else{
htmlStr = '<div style="width:' + this.numWidth + 'px;" class="u-grid-content-num">' + (index+1) + '</div>';
-
+
}
return htmlStr;
};
@@ -339,15 +352,23 @@ const createContentTable = function(createFlag){
}else{
hStr = "";
}
-
+
if(createFlag == 'fixed'){
leftW = parseInt(this.leftW);
idStr = 'fixed_';
cssStr = 'fixed-';
- styleStr = 'style="position:absolute;width:'+this.fixedWidth+'px;left:' + leftW + 'px;' +hStr+'"';
+ if(this.options.fixedFloat == 'right'){
+ styleStr = 'style="position:absolute;width:'+this.fixedWidth+'px;right:0px;' +hStr+'"';
+ }else{
+ styleStr = 'style="position:absolute;width:'+this.fixedWidth+'px;left:' + leftW + 'px;' +hStr+'"';
+ }
tableStyleStr = 'style="width:'+this.fixedWidth+'px;"';
}else{
- leftW = parseInt(this.leftW) + parseInt(this.fixedWidth,0);
+ if(this.options.fixedFloat == 'right'){
+ leftW = parseInt(this.leftW);
+ }else{
+ leftW = parseInt(this.leftW) + parseInt(this.fixedWidth,0);
+ }
idStr = '';
cssStr = '';
styleStr = 'style="position:relative;left:' + leftW + 'px;' +hStr;
@@ -356,7 +377,7 @@ const createContentTable = function(createFlag){
}
// 因为添加overflow-x之后会导致纵向也显示不全,后续出现问题通过修改宽度来实现,不再通过overflow来实现
if(this.options.noScroll){
- styleStr += 'overflow-x:hidden;'
+ styleStr += 'overflow-x:hidden;'
}
styleStr += '"';
tableStyleStr = '';
@@ -611,7 +632,7 @@ const objCompare = function(rootObj, objAry) {
var compareObj = objAry[i];
matchNum += (rootObj == compareObj) ? 1 : 0;
}
- return (matchNum>0) ? true : false;
+ return (matchNum>0) ? true : false;
};
export{
View
@@ -55,7 +55,11 @@ const initContentDivEventFun = function(){
$('#' + this.options.id + '_content_div').on('scroll', function(e) {
oThis.scrollLeft = this.scrollLeft;
oThis.scrollTop = this.scrollTop;
- $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ if(oThis.options.fixedFloat == 'right'){
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + "px");
+ }else{
+ $('#' + oThis.options.id + '_header_table').css('left', oThis.leftW - oThis.scrollLeft + oThis.fixedWidth + "px");
+ }
$('#' + oThis.options.id + '_noRowsShow').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_edit_form').css('left', oThis.scrollLeft + "px");
$('#' + oThis.options.id + '_content_multiSelect').css('top', -oThis.scrollTop + "px");
@@ -66,7 +70,7 @@ const initContentDivEventFun = function(){
}else{
oThis.editClose();
}
-
+
});
// 数据行相关事件
$('#' + this.options.id + '_content_tbody').on('click',function(e){
View
@@ -92,6 +92,7 @@ const initDefault = function(){
contentSelect: true, // 点击内容区是否执行选中逻辑
showEditIcon: false,// 是否显示编辑图标
contentFocus: true, // 点击内容区是否执行focus逻辑
+ fixedFloat: 'left',
}
};
/*

0 comments on commit 9c31d26

Please sign in to comment.