我正在尝试折叠树视图但无法做到这一点请帮助我 你可以从下面链接查看演示我希望树视图最初崩溃每个节点,因为它应该扩展特定节点。
演示
http://www.jqueryscript.net/demo/Animated-Tree-View-Plugin-For-jQuery-Bootstrap-3-MultiNestedLists/
// Select the main list and add the class "hasSubmenu" in each LI that contains an UL
$('ul').each(function(){
$this = $(this);
$this.find("li").has("ul").addClass("hasSubmenu");
$this.find("li").has("ul").css('collapsed', 'true');
});
// Find the last li in each level
$('li:last-child').each(function(){
$this = $(this);
// Check if LI has children
if ($this.children('ul').length === 0){
// Add border-left in every UL where the last LI has not children
$this.closest('ul').css("border-left", "1px solid gray");
} else {
// Add border in child LI, except in the last one
$this.closest('ul').children("li").not(":last").css("border-left","1px solid gray");
// Add the class "addBorderBefore" to create the pseudo-element :defore in the last li
$this.closest('ul').children("li").last().children("a").addClass("addBorderBefore");
// Add margin in the first level of the list
$this.closest('ul').css("margin-top","20px");
// Add margin in other levels of the list
$this.closest('ul').find("li").children("ul").css("margin-top","20px");
};
});
// Add bold in li and levels above
$('ul li').each(function(){
$this = $(this);
$this.mouseenter(function(){
$( this ).children("a").css({"font-weight":"bold","color":"#336b9b"});
});
$this.mouseleave(function(){
$( this ).children("a").css({"font-weight":"normal","color":"#428bca"});
});
});
// Add button to expand and condense - Using FontAwesome
$('ul li.hasSubmenu').each(function(){
$this = $(this);
$this.prepend("<a href='#'><i class='fa fa-minus-circle'></i><i style='display:none;' class='fa fa-plus-circle'></i></a>");
$this.children("a").not(":last").removeClass().addClass("toogle");
});
// Actions to expand and consense
$('ul li.hasSubmenu a.toogle').click(function(){
$this = $(this);
$this.closest("li").children("ul").toggle("slow");
$this.children("i").toggle();
return false;
});
答案 0 :(得分:2)
您可以尝试使用代码。会帮助你。 谢谢
$resultscount = 0;
foreach ($myassignment->result() as $e)
{
...
$resultscount += $getassign->num_rows();
}
if ($resultscount > 0) // good catch, Saty. Thanks!
{
print_r('some rows');
// you can now also use the number of rows in output:
print_r($resultscount . ' row' . ($resultscount > 1 ? 's' : ''));
}
else
print_r('no rows');