I was initially going to submit this ticket for a problem I had getting my grid to call my EndCallBack function, but I eventually discovered the problem was actually caused by a JS error within GridViewFixedGroupsHelper.SetGroupRowCellsWidth JS function which occurring before the call to my EndCallBack function (wgEnd).
The error occurs when I set the settings.SettingsBehavior.AllowFixedGroups = true. If I set to false, the error doesn't occur, but I don't get the functionality that I'm looking for. For me, other than the EndCallBack not firing as needed, everything else with the grid behaves normally; paging works, sorting works, etc.
My partial view for the grid has the following (trimmed down for readability):
C#var grid = Html.DevExpress().GridView<CustomModel>(settings =>
{
settings.Name = "wg";
settings.SettingsSearchPanel.Visible = false;
settings.CallbackRouteValues = new { Controller = "Home", Action = "wgPartial", w = ViewBag.Id };
settings.ClientSideEvents.Init = "wgInit";
settings.ClientSideEvents.BeginCallback = "wgBegin";
settings.ClientSideEvents.EndCallback = "wgEnd";
settings.KeyFieldName = "Id";
settings.SettingsLoadingPanel.Mode = GridViewLoadingPanelMode.Default;
settings.Settings.ShowFilterRow = false;
settings.Settings.VerticalScrollableHeight = 600;
settings.Settings.VerticalScrollBarMode = ScrollBarMode.Visible;
settings.Settings.UseFixedTableLayout = true;
settings.SettingsPager.Mode = GridViewPagerMode.ShowPager;
settings.SettingsPager.PageSize = 30;
settings.Width = Unit.Percentage(100);
settings.Styles.Table.CssClass = "table table-bordered";
settings.Styles.Header.CssClass = "header";
settings.SettingsBehavior.AllowFixedGroups = true;
settings.SettingsBehavior.AllowSelectByRowClick = false;
settings.SettingsBehavior.AutoExpandAllGroups = true;
settings.SettingsBehavior.AllowGroup = false;
settings.SettingsBehavior.AllowDragDrop = false;
settings.SettingsBehavior.AllowSelectByRowClick = false;
settings.SettingsBehavior.AllowSelectSingleRowOnly = false;
settings.SettingsDetail.ShowDetailRow = true;
settings.SettingsDetail.ShowDetailButtons = false;
settings.SettingsDetail.AllowOnlyOneMasterRowExpanded = false;
settings.Columns.Add(m =>
{
m.FieldName = "Prop1";
m.GroupIndex = 0;
m.Caption = "Prop #1";
m.SetGroupRowTemplateContent(diTemplate =>
{
string name = ((string)DataBinder.Eval(diTemplate.DataItem, nameof(CustomModel.Prop1)));
ViewContext.Writer.Write(string.IsNullOrEmpty(name) ? "<i>(No 1 Specified)</i>" : name);
});
});
settings.Columns.Add(m =>
{
m.FieldName = "Prop2";
m.GroupIndex = 1;
m.Caption = "Prop #2";
m.SetGroupRowTemplateContent(diTemplate =>
{
string name = ((string)DataBinder.Eval(diTemplate.DataItem, nameof(CustomModel.Prop2)));
ViewContext.Writer.Write(string.IsNullOrEmpty(name) ? "<i>(No 2 Specified)</i>" : name);
});
});
settings.Columns.Add(m =>
{
m.FieldName = "Prop3";
m.Caption = "Prop #3";
});
settings.Columns.Add(m =>
{
m.FieldName = "Prop4";
m.Caption = "Prop #4";
});
});
@grid.Bind(Model).GetHtml()
With that I get a "Uncaught TypeError: Cannot read property 'style' of undefined" JS error within GridViewFixedGroupsHelper.SetGroupRowCellsWidth:
JavaScriptgroupRow.cells[level + 1].style.width = totalWidth - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(groupRow.cells[level + 1]) + "px";
"groupRow.cells" is an HTMLCollection with one element and "level" == 0". groupRow.cells[0] is the grouped header with "(No 1 Specified)" in it. "level + 1" is undefined, naturally, as the collection only has one element. Once that error is hit, my EndCallBack method never gets called again… unless oddly enough I'm switching from a page > 1 back to page == 1.
Hi,
I have created a small sample project that covers your scenario and operates correctly as shown in the attached screencast. I hope reviewing it will help you find a solution to this problem. If this does not help, please update my sample to illustrate the problem. Then, I will see what is going wrong and do my best to find a solution.
I can replicate the problem in your sample if I adjust one of the grouped columns with the following:
settings.Columns.Add(column => {
column.FieldName = "UnitsOnOrder";
column.GroupIndex = 1;
column.SetGroupRowTemplateContent(diTemplate =>
{
short? units = ((short?)DataBinder.Eval(diTemplate.DataItem, "UnitsOnOrder"));
ViewContext.Writer.Write(!units.HasValue || units == 0 ? "<i>No Orders</i>" : units.ToString());
});
});
It's the overriding of the text in the group header which causes the problem. The GroupText property is read-only, so I resorted to setting it via the SetGroupRowTemplateContent function.
I've attached a screencast of the error occurring.
Hello,
I was able to reproduce this issue on my side and passed this ticket to our developers.
We will update this ticket as soon as we have results.