I use a GridLookup instead of an Combobox. I do this because old inative products should no longer be selected by the user.
The control GridLookup works well, but if I change the value using the keyboard arrows then the Event ValueChanged is only triggerd when the grid view dialog is open. If the grid view dialog is closed and i use keyboard arrows to change the value then the value is indeed changed, but the event ValueChanged is not triggered.
File _GridLookupProduktartPartial.cshtml:
@using Bytergy.App_Code
@model Bytergy.Models.LoanPreCalculation.Vorkalkulation
var gridLookup = Html.DevExpress().GridLookup(s => {
ControlsHelper.DefaultSettings(s);
s.Name = "SelProduktartID";
s.KeyFieldName = "ID";
s.Width = 300;
s.GridViewProperties.CallbackRouteValues = new { Controller = "LoanPreCalculation", Action = "GridLookupProduktartPartial"};
s.Properties.SelectionMode = GridLookupSelectionMode.Single;
s.Properties.TextFormatString = "{0}";
s.GridViewProperties.Settings.ShowGroupPanel = false;
s.GridViewProperties.Settings.ShowFilterRow = false;
s.GridViewProperties.Settings.ShowColumnHeaders = true;
s.GridViewProperties.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
s.GridViewProperties.SettingsBehavior.EnableRowHotTrack = true;
s.Properties.ClientSideEvents.ValueChanged = "OnChangedProduktartID";
s.Properties.ClientSideEvents.Init = "OnInitProduktartID";
s.Properties.ClearButton.DisplayMode = ClearButtonDisplayMode.OnHover;
s.Columns.Add(c =>
{
c.FieldName = "Name";
c.Caption = "Text";
c.Width = Unit.Pixel(300);
});
s.Columns.Add(c =>
{
c.FieldName = "KoreID";
c.Caption = "KoreID";
c.Width = Unit.Pixel(90);
});
s.Columns.Add(c =>
{
c.FieldName = "ID";
c.Caption = "Schlüssel";
c.Width = Unit.Pixel(55);
});
s.Columns.Add(c =>
{
c.FieldName = "Aktiv";
c.Caption = "Aktiv";
// c.Visible = true;
// c.Width = Unit.Pixel(55);
});
s.Columns.Add(c =>
{
c.FieldName = "IsKontokorrent";
c.Caption = "IsKontokorrent";
// c.Visible = true;
// c.Width = Unit.Pixel(55);
});
s.DataBound = (sender, e) =>
{
var gLookup = (MVCxGridLookup)sender;
gLookup.GridView.Width = 300;
gLookup.GridView.Settings.VerticalScrollBarMode = ScrollBarMode.Visible;
gLookup.GridView.Settings.VerticalScrollableHeight = 300;
};
s.GridViewProperties.BeforeGetCallbackResult = (sender, e) =>
{
var grid = (ASPxGridView)sender;
if (grid.VisibleRowCount <= 2)
grid.Settings.VerticalScrollBarMode = ScrollBarMode.Hidden;
};
s.GridViewProperties.HtmlRowCreated = (sender, e) =>
{
var valAktive = e.GetValue("Aktiv");
if (valAktive != null) {
bool aktiv = (bool)(e.GetValue("Aktiv"));
e.Row.Visible = aktiv;
}
else {
e.Row.Visible = true;
}
};
});
}
@gridLookup.BindList(ViewBag.ListProduktart).Bind(Model.ProduktartID).GetHtml()
File EditPage.cshtml:
…
<scripttype="text/javascript">
function OnInitProduktartID(s, e) {
SetVisibilityProduktartID(s);
}
function OnChangedProduktartID(s, e) {
SetVisibilityProduktartID(s);
}
function SetVisibilityProduktartID(s) {
var myVal = s.GetValue();
console.log("Produktart changed to name: " + myVal);
}
</script>
@Html.DevExpress().FormLayout(settings =>
{
…
groupItem.Items.Add(i =>
{
ControlsHelper.DefaultSettings(i);
i.Caption = "Produktart";
i.SetNestedContent(() =>
{
Html.RenderAction("GridLookupProduktartPartial", new { model = Model });
});
});
…
Hi,
The ValueChanged event is raised when selection is changed or the control's value was changed and has lost focus. Would you please describe your scenario in greater detail and illustrate how and why you're using this event, so we can research the problem in greater detail? GridLookup settings and JavaScript code snippets would be helpful as well.
We're looking forward to your reply.
[This comment was created from a user's answer]
Depending on the current value I hide/show other controls. With the attached sample project, the problem can be reproduced.
[JScript]``````[ASPx]
[This comment was created from a user's answer]
At the end of the video you can see that I leave the field with the mouse, however, the event is not fired.
Hello,
Thank you for the provided video and project. I was able to reproduce this behavior, and it seems strange to me.
I have forwarded this ticket to our developers for further research, and we will update it as soon as we have results.
Regards,
Pavlo