【问题标题】:Setting kendoui treeview's checkbox's checked property to true on load在加载时将 kendo ui treeview checkboxes checked 属性设置为 true
【发布时间】:2013-04-20 09:34:29
【问题描述】:

这是我绑定剑道树视图的方式

  @(Html.Kendo().TreeView()
  .Name("treeview")
  .Checkboxes(chkbxs =>
    {
       chkbxs.CheckChildren(true);
    })
  .BindTo((IEnumerable<TreeViewItemModel>)ViewBag.inlineDefault)
   )

如何在加载时将某些复选框的已选中属性设置为 true? TreeViewItemModel中有一个bool属性

【问题讨论】:

    标签: .net asp.net-mvc treeview kendo-ui checkbox


    【解决方案1】:

    您可以使用ItemAction 方法提供一个委托,该委托将每个TreeViewItem 上的Checked 属性设置为true

    此外,您可以在ItemAction 中编写任何条件逻辑来仅检查其中一些:

    @(Html.Kendo().TreeView()
      .Name("treeview")
      .Checkboxes(chkbxs =>
        {                
           chkbxs.CheckChildren(true);
        })
      .ItemAction(item =>
        {
           if (checkSomeCondition(item))
               item.Checked = true;
        })
      .BindTo((IEnumerable<TreeViewItemModel>)ViewBag.inlineDefault)
      )
    

    【讨论】:

    • 但我不希望一切都是真的
    • @PapyrusBit 抱歉,我错过了某些部分。但是您仍然可以使用 ItemAction ... 请参阅我的更新答案。您希望根据什么标准将它们设置为 true?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    相关资源
    最近更新 更多