【问题标题】:Retrieve Highlighted (Selected) options in Listbox (Telerik UI for Asp.net MVC)检索列表框中突出显示的(选定)选项(Telerik UI for Asp.net MVC)
【发布时间】:2021-07-14 17:40:55
【问题描述】:

如果有办法在 Telerik UI for Asp.Net MVC 的“可选”列表框中获取“突出显示”选项,我正在尝试找到它。我知道单击选项列表框中的项目会触发列表框的“onChange”事件,但我不知道如何获取突出显示项目的实际值。

在上面的示例中,我希望返回 Thomas Hardy 和 Christina Berglund,或者至少返回他们的选项 ID。

这是我的列表框定义:

                    @(Html.Kendo().ListBox()
                        .Name("optional")
                        .Toolbar(toolbar =>
                        {
                            toolbar.Position(Kendo.Mvc.UI.Fluent.ListBoxToolbarPosition.Right);
                            toolbar.Tools(tools => tools
                                .MoveUp()
                                .MoveDown()
                                .TransferTo()
                                .TransferFrom()
                                .TransferAllTo()
                                .TransferAllFrom()
                                .Remove()
                            );
                        })
                        .Events(events => events
                        .Change("onChange"))
                        .ConnectWith("selected")
                        .Selectable(ListBoxSelectable.Multiple)
                        .Draggable()
                        .DropSources("selected")
                        .DataTextField("FullName")
                        .DataValueField("EmployeeCompanyId")
                        .DataSource(source => source
                            .Read(read => read.Action("GetEmployees", "Setup", new { area = "Admin" }))
                        )

                    )

这是我的 onChange 函数:

    function onChange(e) {
    var item = e.sender.element;
}

【问题讨论】:

    标签: telerik-mvc


    【解决方案1】:

    好的,我想通了。我将“onChange”函数更改为:

       function onChange(e) {
        var item = e.sender.dataItem(e.sender.select());
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      • 1970-01-01
      • 1970-01-01
      • 2012-04-15
      相关资源
      最近更新 更多