Kendo UI - 从重复编辑器中隐藏“结束:从不”选项

Posted

技术标签:

【中文标题】Kendo UI - 从重复编辑器中隐藏“结束:从不”选项【英文标题】:Kendo UI - Hide "End: Never" option from Recurrence Editor 【发布时间】:2014-07-14 16:26:57 【问题描述】:

我在以标准化方式隐藏重复编辑器中的一个选项时遇到了麻烦。我试图通过自定义代码隐藏它,但它有时会产生不可预测的行为。

这就是我想要隐藏的:

【问题讨论】:

【参考方案1】:

您需要处理调度程序的编辑事件并通过 jQuery 隐藏该选项:

function scheduler_edit(e) 
  // find the recurring dropdownlist 
  var dropdown = e.container.find("[data-role=dropdownlist]").data("kendoDropDownList");

  // handle its change event
  dropdown.unbind("change", hide_never);
  dropdown.bind("change", hide_never);


function hide_never() 
  // hide the <li> element that contains the "Never" radio option
  $(".k-recur-end-never").closest("li").hide();

【讨论】:

我在我的自定义编辑器模板中添加了其他下拉菜单,所以上面的代码没有找到重复编辑器下拉菜单。相反,我需要使用e.container.find("[data-role=recurrenceeditor]")【参考方案2】:

你也可以这样做:

在小部件的edit 事件中:

  var recurrenceEditor = e.container.find("[data-role=recurrenceeditor]").data("kendoRecurrenceEditor");     

            //set start option value, used to define the week 'Repeat on' selected checkboxes
            recurrenceEditor.setOptions(
                start: new Date(e.event.start),
                change: function (e)  onRecurrenceEditor_Change(e,this); 
            );

然后:

 function onRecurrenceEditor_Change(e, obj) 
        var buttonNever = obj._buttonNever;

        if (buttonNever) 
            $(buttonNever[0]).parent().remove();
        
    

【讨论】:

【参考方案3】:

我刚收到 Telerik 支持的回复,我为此付费。拼接下拉列表的数据并重新设置:

edit: function (e) 
    // remove Yearly" from re-occurence dropdown
    var ddl = $('input[title="Recurrence editor"]').data('kendoDropDownList');
    if (ddl) 
      var data = ddl.dataSource.data();
      data = data.slice(0, 4);
      ddl.setDataSource(data);
    
,

Working Dojo.

【讨论】:

这并不能解决有关删除“从不”选项的问题。您提供的剪辑只会从下拉列表中删除“每年”。 @Amacado 对;只需使用 data.slice(1) 代替;你只是在操纵数组;不过,他们在 2020 版本中不再使用数组

以上是关于Kendo UI - 从重复编辑器中隐藏“结束:从不”选项的主要内容,如果未能解决你的问题,请参考以下文章

Kendo UI Hierarchical datagrid - 如何从详细网格编辑器模板 MVVM 访问根视图模型

在 Kendo UI Chart Angular 2 中隐藏网格线

在 kendo-ui 网格中显示/隐藏列后,有啥方法可以自动调整网格列宽?

MVC 中的 KENDO UI 网格:有没有办法在某些列上隐藏过滤器?

MVC Grid 的 Kendo UI 如何隐藏 ID 列

来自弹出编辑器的Kendo UI绑定下拉值