mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-17 16:10:04 +01:00
Fixed grid layout bug with IE
This commit is contained in:
parent
8774c670ff
commit
e07aa52df9
13 changed files with 1272 additions and 538 deletions
|
|
@ -39,6 +39,8 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
//defines col resizer script path
|
||||
this.gridColResizerPath = f.grid_cont_col_resizer_path || this.basePath + "TFExt_ColsResizer/TFExt_ColsResizer.js";
|
||||
|
||||
this.gridColElms = [];
|
||||
|
||||
this.tf = tf;
|
||||
};
|
||||
|
||||
|
|
@ -50,6 +52,10 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
var f = tf.fObj;
|
||||
var tbl = tf.tbl;
|
||||
|
||||
if (!tf.gridLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
tf.isExternalFlt = true;
|
||||
|
||||
// default width of 100px if column widths not set
|
||||
|
|
@ -172,21 +178,21 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
this.headTbl.cellPadding = tbl.cellPadding;
|
||||
this.headTbl.cellSpacing = tbl.cellSpacing;
|
||||
|
||||
//Headers container width
|
||||
this.headTblCont.style.width = this.tblCont.clientWidth + "px";
|
||||
|
||||
//content table without headers needs col widths to be reset
|
||||
tf.SetColWidths();
|
||||
|
||||
//Headers container width
|
||||
this.headTblCont.style.width = this.tblCont.clientWidth + "px";
|
||||
|
||||
tbl.style.width = "";
|
||||
if (Helpers.isIE()) {
|
||||
this.headTbl.style.width = "";
|
||||
}
|
||||
// if(Helpers.isIE()){
|
||||
// this.headTbl.style.width = '';
|
||||
// }
|
||||
|
||||
//scroll synchronisation
|
||||
var o = this; //TF object
|
||||
var o = this;
|
||||
|
||||
Event.add(this.tblCont, "scroll", function () {
|
||||
Event.add(this.tblCont, "scroll", function (evt) {
|
||||
//this = scroll element
|
||||
var scrollLeft = this.scrollLeft;
|
||||
o.headTblCont.scrollLeft = scrollLeft;
|
||||
|
|
@ -243,78 +249,82 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
|
||||
//Cols generation for all browsers excepted IE<=7
|
||||
o.tblHasColTag = Dom.tag(tbl, "col").length > 0 ? true : false;
|
||||
if (!Helpers.isIE()) {
|
||||
//Col elements are enough to keep column widths after sorting and
|
||||
//filtering
|
||||
var createColTags = function (o) {
|
||||
if (!o) {
|
||||
return;
|
||||
}
|
||||
for (var k = (o.nbCells - 1); k >= 0; k--) {
|
||||
var col = Dom.create("col", ["id", o.id + "_col_" + k]);
|
||||
tbl.firstChild.parentNode.insertBefore(col, tbl.firstChild);
|
||||
col.style.width = o.colWidth[k];
|
||||
o.gridColElms[k] = col;
|
||||
}
|
||||
o.tblHasColTag = true;
|
||||
};
|
||||
if (!o.tblHasColTag) {
|
||||
createColTags(o);
|
||||
} else {
|
||||
var cols = Dom.tag(tbl, "col");
|
||||
for (var ii = 0; ii < o.nbCells; ii++) {
|
||||
cols[ii].setAttribute("id", o.id + "_col_" + ii);
|
||||
cols[ii].style.width = o.colWidth[ii];
|
||||
o.gridColElms.push(cols[ii]);
|
||||
}
|
||||
|
||||
// if(!Helpers.isIE()){
|
||||
//Col elements are enough to keep column widths after sorting and
|
||||
//filtering
|
||||
var createColTags = function (o) {
|
||||
if (!o) {
|
||||
return;
|
||||
}
|
||||
for (var k = (tf.nbCells - 1); k >= 0; k--) {
|
||||
var col = Dom.create("col", ["id", tf.id + "_col_" + k]);
|
||||
tbl.firstChild.parentNode.insertBefore(col, tbl.firstChild);
|
||||
col.style.width = tf.colWidth[k];
|
||||
o.gridColElms[k] = col;
|
||||
}
|
||||
o.tblHasColTag = true;
|
||||
};
|
||||
if (!o.tblHasColTag) {
|
||||
createColTags(o);
|
||||
} else {
|
||||
var cols = Dom.tag(tbl, "col");
|
||||
for (var ii = 0; ii < tf.nbCells; ii++) {
|
||||
cols[ii].setAttribute("id", tf.id + "_col_" + ii);
|
||||
cols[ii].style.width = tf.colWidth[ii];
|
||||
o.gridColElms.push(cols[ii]);
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
//IE <= 7 needs an additional row for widths as col element width is
|
||||
//not enough...
|
||||
if (Helpers.isIE()) {
|
||||
var tbody = Dom.tag(tbl, "tbody"), r;
|
||||
if (tbody.length > 0) {
|
||||
r = tbody[0].insertRow(0);
|
||||
} else {
|
||||
r = tbl.insertRow(0);
|
||||
}
|
||||
r.style.height = "0px";
|
||||
for (var x = 0; x < o.nbCells; x++) {
|
||||
var col = Dom.create("td", ["id", o.id + "_col_" + x]);
|
||||
col.style.width = o.colWidth[x];
|
||||
tbl.rows[1].cells[x].style.width = "";
|
||||
r.appendChild(col);
|
||||
o.gridColElms.push(col);
|
||||
}
|
||||
this.hasGridWidthsRow = true;
|
||||
//Data table row with widths expressed
|
||||
o.leadColWidthsRow = tbl.rows[0];
|
||||
o.leadColWidthsRow.setAttribute("validRow", "false");
|
||||
// if(Helpers.isIE()){
|
||||
// var tbody = Dom.tag(tbl,'tbody'),
|
||||
// r;
|
||||
// if( tbody.length>0 ){
|
||||
// r = tbody[0].insertRow(0);
|
||||
// } else{
|
||||
// r = tbl.insertRow(0);
|
||||
// }
|
||||
// r.style.height = '0px';
|
||||
// for(var x=0; x<o.nbCells; x++){
|
||||
// var col = Dom.create('td', ['id', o.id+'_col_'+x]);
|
||||
// col.style.width = o.colWidth[x];
|
||||
// tbl.rows[1].cells[x].style.width = '';
|
||||
// r.appendChild(col);
|
||||
// o.gridColElms.push(col);
|
||||
// }
|
||||
// tf.hasGridWidthsRow = true;
|
||||
// //Data table row with widths expressed
|
||||
// o.leadColWidthsRow = tbl.rows[0];
|
||||
// o.leadColWidthsRow.setAttribute('validRow', 'false');
|
||||
|
||||
var beforeSortFn = Types.isFn(f.on_before_sort) ? f.on_before_sort : null;
|
||||
f.on_before_sort = function (o, colIndex) {
|
||||
o.leadColWidthsRow.setAttribute("validRow", "false");
|
||||
if (beforeSortFn) {
|
||||
beforeSortFn.call(null, o, colIndex);
|
||||
}
|
||||
};
|
||||
// var beforeSortFn = Types.isFn(f.on_before_sort) ?
|
||||
// f.on_before_sort : null;
|
||||
// f.on_before_sort = function(o, colIndex){
|
||||
// o.leadColWidthsRow.setAttribute('validRow', 'false');
|
||||
// if(beforeSortFn){
|
||||
// beforeSortFn.call(null, o, colIndex);
|
||||
// }
|
||||
// };
|
||||
|
||||
var afterSortFn = Types.isFn(f.on_after_sort) ? f.on_after_sort : null;
|
||||
f.on_after_sort = function (o, colIndex) {
|
||||
if (o.leadColWidthsRow.rowIndex !== 0) {
|
||||
var r = o.leadColWidthsRow;
|
||||
if (tbody.length > 0) {
|
||||
tbody[0].moveRow(o.leadColWidthsRow.rowIndex, 0);
|
||||
} else {
|
||||
tbl.moveRow(o.leadColWidthsRow.rowIndex, 0);
|
||||
}
|
||||
}
|
||||
if (afterSortFn) {
|
||||
afterSortFn.call(null, o, colIndex);
|
||||
}
|
||||
};
|
||||
}
|
||||
// var afterSortFn = Types.isFn(f.on_after_sort) ?
|
||||
// f.on_after_sort : null;
|
||||
// f.on_after_sort = function(o,colIndex){
|
||||
// if(o.leadColWidthsRow.rowIndex !== 0){
|
||||
// var r = o.leadColWidthsRow;
|
||||
// if(tbody.length>0){
|
||||
// tbody[0].moveRow(o.leadColWidthsRow.rowIndex, 0);
|
||||
// } else {
|
||||
// tbl.moveRow(o.leadColWidthsRow.rowIndex, 0);
|
||||
// }
|
||||
// }
|
||||
// if(afterSortFn){
|
||||
// afterSortFn.call(null, o, colIndex);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
var afterColResizedFn = Types.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null;
|
||||
f.on_after_col_resized = function (o, colIndex) {
|
||||
|
|
@ -328,11 +338,11 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
var thCW = o.crWColsRow.cells[colIndex].clientWidth;
|
||||
var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
|
||||
|
||||
if (Helpers.isIE()) {
|
||||
tbl.style.width = o.headTbl.clientWidth + "px";
|
||||
}
|
||||
// if(Helpers.isIE()){
|
||||
// tbl.style.width = o.headTbl.clientWidth+'px';
|
||||
// }
|
||||
|
||||
if (thCW != tdCW && !Helpers.isIE()) {
|
||||
if (thCW != tdCW /*&& !Helpers.isIE()*/) {
|
||||
o.headTbl.style.width = tbl.clientWidth + "px";
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +356,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
}
|
||||
|
||||
// Re-adjust reference row
|
||||
tf.refRow = Helpers.isIE() ? (tf.refRow + 1) : 0;
|
||||
//tf.refRow = Helpers.isIE() ? (tf.refRow+1) : 0;
|
||||
}
|
||||
},
|
||||
destroy: {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue