DevExpress MVC 17.1如何在LargeDataComboBox中调用ValueChange事件时打开弹出窗口

时间:2017-10-09 17:15:57

标签: devexpress devexpress-mvc

我需要在调用LargeDataComboBox的ValueChanged事件时(当我点击下拉列表中的某行时)显示一个弹出窗口。

_searchPanel.cshtml

    @Html.DevExpress().ComboBox(
    settings =>
    {
        settings.Name = "comboBoxSearchPanel";
        settings.Height = 30;
        settings.SelectedIndex = 0;
        settings.Properties.DropDownStyle = DropDownStyle.DropDown;
        settings.CallbackRouteValues = new { Controller = "SearchPanel", Action = "SearchPanel" };
        settings.Properties.CallbackPageSize = 30;
        settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
        settings.Properties.FilterMinLength = 2;
        settings.Properties.ClearButton.DisplayMode = ClearButtonDisplayMode.OnHover;
        settings.Properties.ValueField = "id_usuario";
        settings.Properties.ValueType = typeof(string);
        settings.Properties.TextFormatString = "{0} {1}";
        settings.Properties.Columns.Add(column =>
        {
            column.FieldName = "iduser";
            column.Caption = "User";
        });
        settings.Properties.Columns.Add(column =>
        {
            column.FieldName = "fullname";
            column.Caption = "FUllName";
            column.Width = 175;
        });
        settings.Properties.ClientSideEvents.ValueChanged = "function(s, e) { OnValueChangeSearchPanel(s, e)}";
    }
).BindList(Model).GetHtml()

函数,其中调用ValueChanged事件

    function OnValueChangeSearchPanel(s, e) {
        var x = s.GetSelectedItem().text.split(" ");
        console.log(x[0]);
//I need to replace the alert with a popup
        alert(x[0]);
    }

_popupWindow.cshtml

@Html.DevExpress().PopupControl(settings =>
{
    settings.Name = "popupUser";
    settings.AllowDragging = true;
    settings.ShowOnPageLoad = true;
    settings.CloseAction = CloseAction.CloseButton;
    settings.HeaderText = "User";
    settings.SetContent(() =>
    {
        ViewContext.Writer.Write(
          "<h1>" + "Welcome" + "</h1>"
        );
    });

它应该如何运作的图表

enter image description here

1 个答案:

答案 0 :(得分:0)

下面的代码可以解决问题

function OnValueChangeSearchPanel(s, e) {
        var x = s.GetSelectedItem().text.split(" ");
        popupUser.Show();
    }

你的助手应该是这样的(完整代码here

@Html.DevExpress().PopupControl(settings =>
{
    settings.Name = "popupUser";
    settings.AllowDragging = true;
    settings.ShowOnPageLoad = true;
    settings.EnableClientSideAPI = true;
    settings.CloseAction = CloseAction.CloseButton;
    settings.PopupAction = PopupAction.None;
    settings.HeaderText = "User";
    settings.SetContent(() =>
    {
        ViewContext.Writer.Write(
          "<h1>" + "Welcome" + "</h1>"
        );
    });