【问题标题】:Get Kendo PanelBar index获取 Kendo PanelBar 索引
【发布时间】:2018-01-08 11:53:34
【问题描述】:

我的 Kendo 面板栏有一个 onSelect 函数

我希望能够获取所选面板的索引。

Kendo 文档中的示例获取面板的名称:

$(e.item).find("> .k-link").text())

我只想返回 0(用于顶部面板)、1、2、3 等。

谢谢,

【问题讨论】:

    标签: jquery kendo-panelbar


    【解决方案1】:

    id 添加到每个面板标题,即可点击部分。然后你可以使用这样的东西。

    $('.k-header').on('click', function(){
      var index = $(this).attr('id');
      var name = $(this).text();
      $('#output').html("name: "+name+"<br>"+"index: "+index);
    });
    span {
     border:2px solid cyan;
     border-radius:3px;
     display:block;
     padding:10px;
     width:300px;
     margin-bottom:10px;
     cursor:pointer;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <span id="0" class="k-link k-header k-state-selected">
    The Dark Knight
    </span>
    <span id="1" class="k-link k-header k-state-selected">
    The Wicker Man
    </span>
    <span id="2" class="k-link k-header k-state-selected">
     The Man of Steel 
    </span>
    
    <div id="output"></div>

    【讨论】:

    • 我正在使用 Razor 引擎,所以不知道该怎么做: panelbar.Add().Text("Section 1") .Expanded(true) .Content(@
      hello1
      );
    • 所以你是说 HTML 是动态生成的?
    【解决方案2】:

    我知道这是一篇旧帖子,但无论如何这里有一个答案:

    e.item 是一个列表项,所以你只需要$( e.item ).index()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多