Permalink
Browse files

feat: grid组件支持动态设置固定列

  • Loading branch information...
LiuYueKai committed Mar 28, 2017
1 parent c379ca0 commit 30ef645e06ac2eef275553d20d916f74c0686018
Showing with 36 additions and 1 deletion.
  1. +11 −0 src/js/gridCompGet.js
  2. +25 −1 src/js/re_gridCompFixed.js
View
@@ -7,6 +7,11 @@ const getColumnAttr = function(attr, field) {
return $(this.gridCompColumnArr[i].options).attr(attr);
}
}
+ for (var i = 0; i < this.gridCompColumnFixedArr.length; i++) {
+ if (this.gridCompColumnFixedArr[i].options.field == field) {
+ return $(this.gridCompColumnFixedArr[i].options).attr(attr);
+ }
+ }
return "";
};
/*
@@ -18,6 +23,12 @@ const getColumnByField = function(field) {
return this.gridCompColumnArr[i];
}
}
+ for (var i = 0; i < this.gridCompColumnFixedArr.length; i++) {
+ if (this.gridCompColumnFixedArr[i].options.field == field) {
+ return this.gridCompColumnFixedArr[i];
+ }
+ }
+
return null;
};
/*
View
@@ -7,11 +7,26 @@ import {
const re_initGridCompFixedColumn = function() {
var oThis = this;
var w = 0;
+ var removeArr = [];
$.each(this.gridCompColumnArr, function(i) {
if (this.options.fixed == true) {
oThis.gridCompColumnFixedArr.push(this);
}
});
+ $.each(this.gridCompColumnFixedArr, function(i) {
+ if (this.options.fixed != true) {
+ oThis.gridCompColumnArr.push(this);
+ removeArr.push(this)
+ }
+ })
+ $.each(removeArr, function(i) {
+ for (var i = oThis.gridCompColumnFixedArr.length; i > -1; i--) {
+ if (this == oThis.gridCompColumnFixedArr[i]) {
+ oThis.gridCompColumnFixedArr.splice(i, 1);
+ break;
+ }
+ }
+ })
$.each(this.gridCompColumnFixedArr, function(i) {
for (var i = oThis.gridCompColumnArr.length; i > -1; i--) {
if (oThis.gridCompColumnArr[i] == this) {
@@ -54,11 +69,20 @@ const re_widthChangeGridFunFixed = function(halfWholeWidth) {
this.fixedWidth = this.fixedRealWidth;
}
}
+
+const setColumnFixed = function(field, fixed) {
+ var gridCompColumn = this.getColumnByField(field);
+ gridCompColumn.options.fixed = fixed;
+ this.initGridCompFixedColumn();
+ this.repaintDivs();
+}
+
export const fixFunObj = {
initGridCompFixedColumn: re_initGridCompFixedColumn,
fixed_columnsVisibleFun: fixed_columnsVisibleFun,
createHeaderTableFixed: re_createHeaderTableFixed,
createContentTableFixed: re_createContentTableFixed,
createContentOneRowFixed: re_createContentOneRowFixed,
- widthChangeGridFunFixed: re_widthChangeGridFunFixed
+ widthChangeGridFunFixed: re_widthChangeGridFunFixed,
+ setColumnFixed: setColumnFixed
}

0 comments on commit 30ef645

Please sign in to comment.