使用JavaScript在devexpress组合框中获取所选项目id

bqujaahr  于 2023-09-29  发布在  Java
关注(0)|答案(1)|浏览(93)

我有一个devexpress combobx:

Html.DevExpress().ComboBox(s =>
{
    s.Name = idPola;
    s.Style.Add("float", "left");
    foreach (SelectListItem item in list)
    {
        s.Properties.Items.Add(new ListEditItem()
        {
            Text = item.Text,
            Value = item.Value,
            Selected = item.Value == selectedValue
        });
    }
    s.SelectedIndex = selectedIndex;
    s.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
    s.ClientVisible = ControlVisible;
    if (Model.Alternative)
    {
        s.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e){ffff(s)}";
    }
    else
    {
        s.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e){HideTextBox(s,e)}";
    }
    s.Properties.EnableClientSideAPI = true;
}).Render();

如何在HideTextBox函数中使用JavaScript获取所选项目的id?

mrphzbgm

mrphzbgm1#

使用客户端GetValue方法:

function HideTextBox(s, e) {
    //s == ComboBox
    var value = s.GetValue();
    alert(value);
}

相关问题