我正在创建多个slickGrids并将它们放在jQuery选项卡中。 第一个jQuery选项卡上的第一个slickGrid工作正常,但是当我切换到下一个选项卡时 在您调整标题大小并且列未与标题对齐之前,slickGrid上的数据列不会显示。有什么办法可以解决这个问题吗? 这是我的代码exerp:
<ul class="tabs">
<li><a href="#tab_1">FADF Mono</a></li>
<li><a href="#tab_2">BADF Mono</a></li>
<li><a href="#tab_3">BADF Color</a></li>
</ul>
<div class="tab_container">
<div id="tab_1" class="tab_content">
<div id="slickGrid_1"></div>
</div>
<div id="tab_2" class="tab_content">
<div id="slickGrid_2"></div>
</div>
<div id="tab_3" class="tab_content">
<div id="slickGrid_3"></div>
</div>
</div>
答案 0 :(得分:9)
好。好吧,我会尝试分解正在发生的事情以及它为什么不起作用。基本上可能发生的是你在初始化你的slickgrid表达之前设置你的标签。这一点很重要,因为您的第二个和第三个选项卡基本上处于隐藏状态,因此您的slickgrids不会初始化。
尝试更改订单,看看是否有效。如果没有,那么我建议将slickfgrid初始化器放入document.ready,将tab初始化器放入document.load。这有点hacky,但产生了良好的结果。
希望这是有道理的。
答案 1 :(得分:3)
您应该将网格加载移动到jQuery选项卡的“show”事件中。我不得不使用这些事件而不是document.ready / load,因为我有我的标签'CSS显示无删除“标签闪存”,即使这种情况发生在页面加载和标签初始化时也是如此。我有这样的东西:
$('#tabs').tabs({
fx: [
{opacity: 'toggle', duration: 'fast'},
{opacity: 'toggle', duration: 'fast'}
],
show: function(event, ui) {
if($(ui.tab).text() == "grids" && !this.gloaded) {
grids.init();
this.gloaded = true;
}
}
});
答案 2 :(得分:1)
好像你可能正在努力解决我遇到的同样问题。 Jquery选项卡隐藏行为会在IE和Chrome上运行到slickgrid渲染。 FIrefox渲染得很好。 这就是我所说的 - 对jquery UI CSS进行以下修改 -
这
.ui-tabs .ui-tabs-hide { display: none !important; }
到
.ui-tabs .ui-tabs-hide {
position: absolute;
left: -10000px;
}
答案 3 :(得分:0)
这基本上是我的jquery的代码重建,这段代码是由php代码动态生成的。
$(document).ready(function() {
//When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
</script>
<script>
var grid_1;
var columns_1 = [
{id:"title", name:"Title", field:"title"},
{id:"duration", name:"Duration", field:"duration"},
{id:"%", name:"% Complete", field:"percentComplete"},
{id:"start", name:"Start", field:"start"},
{id:"finish", name:"Finish", field:"finish"},
{id:"effort-driven", name:"Effort Driven", field:"effortDriven"}
];
var options_1 = {
enableCellNavigation: false,
enableColumnReorder: false
};
$(function() {
var data_1 = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid_1 = new Slick.Grid($("#slickGrid_1"), data_1, columns_1, options_1);
})
</script>
<script>
var grid_2;
var columns_2 = [
{id:"title", name:"Title", field:"title"},
{id:"duration", name:"Duration", field:"duration"},
{id:"%", name:"% Complete", field:"percentComplete"},
{id:"start", name:"Start", field:"start"},
{id:"finish", name:"Finish", field:"finish"},
{id:"effort-driven", name:"Effort Driven", field:"effortDriven"}
];
var options_2 = {
enableCellNavigation: false,
enableColumnReorder: false
};
$(function() {
var data_2 = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid_2 = new Slick.Grid($("#slickGrid_2"), data_2, columns_2, options_2);
})
</script>
<script>
var grid_3;
var columns_3 = [
{id:"title", name:"Title", field:"title"},
{id:"duration", name:"Duration", field:"duration"},
{id:"%", name:"% Complete", field:"percentComplete"},
{id:"start", name:"Start", field:"start"},
{id:"finish", name:"Finish", field:"finish"},
{id:"effort-driven", name:"Effort Driven", field:"effortDriven"}
];
var options_3 = {
enableCellNavigation: false,
enableColumnReorder: false
};
$(function() {
var data_3 = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid_3 = new Slick.Grid($("#slickGrid_3"), data_3, columns_3, options_3);
})
</script>