【问题标题】:jqxTree scrolling to the top by collapse/expand nodesjqxTree 通过折叠/展开节点滚动到顶部
【发布时间】:2018-07-31 20:03:48
【问题描述】:

当我折叠或展开 jqxTree 中的节点时,容器元素的滚动条将移至顶部。

是否可以避免这种行为?

为小部件设置固定高度的解决方案对我不利。我需要动态高度。只有当我有一个带有滚动条的容器 div 时才有可能。

http://jsfiddle.net/ccegq/633/

要重现问题,请打开小提琴向下滚动并折叠/展开任何节点。

html:

<div id='div1'>
  <div id='jqxTree'>
      <ul>
          <li item-selected='true'>Home</li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
          <li item-expanded='true'>Solutions
              <ul>
                  <li>Education</li>
                  <li>Financial services</li>
                  <li>Government</li>
                  <li>Manufacturing</li>
                  <li>Solutions
                      <ul>
                          <li>Consumer photo and video</li>
                          <li>Mobile</li>
                          <li>Rich Internet applications</li>
                          <li>Technical communication</li>
                          <li>Training and eLearning</li>
                          <li>Web conferencing</li>
                      </ul>
                  </li>
                  <li>All industries and solutions</li>
              </ul>
          </li>
      </ul>
  </div>
</div>

JavaScript:

$('#jqxTree').jqxTree({ 主题:“能量蓝” });

CSS:

#div1 {
  overflow-y: scroll;
  height: 300px;
  max-height: 300px;
}

【问题讨论】:

    标签: javascript html jqxwidgets


    【解决方案1】:
     $('#jqxTree').jqxTree({
           theme: 'energyblue',
           height:300
       });
    

    为树设置一个高度。这将解决您的问题。 您看到的卷轴不是来自 jqxTree。希望对您有所帮助。

    【讨论】:

    • 谢谢,但正如我在问题中所写:“为小部件设置固定高度的解决方案对我不利。”
    • 以编程方式计算高度。例如: $( 窗口 ).height(); // 返回 HTML 文档的高度 $( document ).height();
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    • 2014-12-18
    相关资源
    最近更新 更多