Current filter:
                                You should refresh the page.
                                  • Hi,

                                           CustomUnboundColumnData event crashes when working with large data. I'm using paging and first 50 pages works well. But when click last page (in my sample 97 pages) web application crashes. I siwtch the listview to server mode but same. I'm realy stucked and i couldn't solve this issue.

                                    [C#]
                                    void grid_CustomUnboundColumnData(object sender, ASPxGridViewColumnDataEventArgs e) { if (grid != null) { if (e.Column.FieldName == _strbalance && e.IsGetData ) { int visibleIndex = grid.FindVisibleIndexByKeyValue(e.GetListSourceFieldValue("Oid")); e.Value = (visibleIndex != 0) ? (Convert.ToDouble(grid.GetRowValues(visibleIndex, "Inbound")) - Convert.ToDouble(grid.GetRowValues(visibleIndex, "Outbound"))) + Convert.ToDouble(grid.GetRowValues(visibleIndex - 1, _strbalance)) : (Convert.ToDouble(grid.GetRowValues(visibleIndex, "Inbound")) - Convert.ToDouble(grid.GetRowValues(visibleIndex, "Outbound"))); } } }
                                    [C#]
                                    void grid_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == _strbalance) { e.Cell.Font.Bold = true; if (Convert.ToDouble(e.CellValue) < 0) e.Cell.ForeColor = System.Drawing.Color.Red; else e.Cell.ForeColor = System.Drawing.Color.Green; } }
                                • Andrey K (DevExpress Support) 07.25.2018

                                  Hello,

                                  XAF uses the ASPxGridView component as an integrated part of our ASPxGridListEditor wrapper and doesn't provide a specific mechanism to handle this scenario. As the behavior you asked for is related directly to the ASPxGridView  engine, I am forwarding your ticket to our ASP.NET team for a follow-up. They are able to provide you with the most suitable answer on how to achieve the required results. Please await a final response on your inquiry from them.
                                  As far as XAF is concerned, you can access the grid component within an XAF ListView as described at Access Grid Control Properties.  Let me know if you experience any further difficulties with the XAF integration.

                                  Thanks,
                                  Andrey

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                A cell value of your unbound column is dynamically calculated depending on the previous value. Since these values are calculated and are not stored in a data source, the code in the Grid_CustomUnboundColumnData event handler is recursive. While your application is running, this recursion may cause the "stack overflow" exception if the number of iterations is too large. Thus, your scenario cannot be correctly implemented by using ASPxGridView methods.
                                To resolve the issue, I suggest you get necessary row values directly from your data source. Please note that this subject does not relate to our ASPxGridView and we do not provide support for 3rd party products, such as the MS SQL server. As a matter of courtesy, we found a solution for you. In particular, use the following code as a SQL View:

                                [SQL]
                                USE [T658623usr] GO /****** Object: View [dbo].[Test] Script Date: 26-Jul-18 13:19:13 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE VIEW [dbo].[Test] AS SELECT [ID], [Inbound], [Outbound], sum(Inbound - Outbound) OVER (ORDER BY ID) AS Balance FROM [T658623usr].[dbo].MyTable GO

                                Then, use the following SelectCommand to get data from this view:

                                [ASPx]
                                <asp:SqlDataSource ID="ds1" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWINDConnectionString %>" SelectCommand="SELECT * FROM [Test]" />

                                In XAF application, you will not need to create a SQL View, because it is possible to switch a ListView to the DataView Data Access Mode. In this mode, the ListView dynamically generates an SQL query based on visible columns.

                                To include the running total calculation into a generated SQL query, create and register a Custom Criteria Language Operator. For your convenience, I added a code snippet demonstrating the RunningTotal function implementation for MS SQL Server. You can easily extend it by adding your own "if" statement if you are using a different database system.

                                [C#]
                                using System; using System.Globalization; using DevExpress.Data.Filtering; using DevExpress.Xpo.DB; public class RunningTotalFunction :ICustomFunctionOperatorFormattable { #region ICustomFunctionOperatorFormattable Members string ICustomFunctionOperatorFormattable.Format(Type providerType, params string[] operands) { if(providerType == typeof(MSSqlConnectionProvider)) { string pattern = "sum({0}) over (order by {1})"; return string.Format(CultureInfo.InvariantCulture, pattern, operands[0], operands[1]); } throw new ArgumentException("The specified provider is not supported", providerType.ToString()); } #endregion #region ICustomFunctionOperator Members object ICustomFunctionOperator.Evaluate(params object[] operands) { return 0; } string ICustomFunctionOperator.Name { get { return "RunningTotal"; } } Type ICustomFunctionOperator.ResultType(params Type[] operands) { return operands[0]; } #endregion }

                                To register your Custom Operator, call the CriteriaOperator.RegisterCustomFunction method in the Module's Setup method. Then, add a read-only Balance property to your persistent class, and decorate it with the PersistentAlias attribute. This attribute allows you to specify the expression where you can use your Custom Operator.

                                Since you cannot calculate the property value on the client-side, I suggest that you return a zero value in the property getter. ListView will not call the property getter in the DataView mode, because the property value will be loaded from the database.

                                [C#]
                                [PersistentAlias("RunningTotal(Inbound - Outbound, CreatedOn)")] public decimal Balance { get { return 0m; } }

                                Attached is a sample project for your reference. I also updated the answer above for consistency.

                                See also:
                                SQL Server Documentation
                                Public questions tagged [sql-server]

                                • Kartal TURGUT 07.26.2018

                                  Thank you. But how can i implement this method on Xaf web app?

                                • Romeo (DevExpress Support) 07.26.2018

                                  To process your question more efficiently, I will transfer this ticket to our XAF team. They will answer your question shortly.

                                  Regards,
                                  Romeo

                                • Uriah (DevExpress Support) 07.26.2018

                                  Hello Kartal,

                                  In XAF application, you will not need to create a SQL View, because it is possible to switch a ListView to the DataView Data Access Mode. In this mode, the ListView dynamically generates an SQL query based on visible columns.

                                  To include the running total calculation into a generated SQL query, create and register a Custom Criteria Language Operator. For your convenience, I added a code snippet demonstrating the RunningTotal function implementation for MS SQL Server. You can easily extend it by adding your own "if" statement if you are using a different database system.

                                  [C#]
                                  using System; using System.Globalization; using DevExpress.Data.Filtering; using DevExpress.Xpo.DB; public class RunningTotalFunction :ICustomFunctionOperatorFormattable { #region ICustomFunctionOperatorFormattable Members string ICustomFunctionOperatorFormattable.Format(Type providerType, params string[] operands) { if(providerType == typeof(MSSqlConnectionProvider)) { string pattern = "sum({0}) over (order by {1})"; return string.Format(CultureInfo.InvariantCulture, pattern, operands[0], operands[1]); } throw new ArgumentException("The specified provider is not supported", providerType.ToString()); } #endregion #region ICustomFunctionOperator Members object ICustomFunctionOperator.Evaluate(params object[] operands) { return 0; } string ICustomFunctionOperator.Name { get { return "RunningTotal"; } } Type ICustomFunctionOperator.ResultType(params Type[] operands) { return operands[0]; } #endregion }

                                  To register your Custom Operator, call the CriteriaOperator.RegisterCustomFunction method in the Module's Setup method. Then, add a read-only Balance property to your persistent class, and decorate it with the PersistentAlias attribute. This attribute allows you to specify the expression where you can use your Custom Operator.

                                  Since you cannot calculate the property value on the client-side, I suggest that you return a zero value in the property getter. ListView will not call the property getter in the DataView mode, because the property value will be loaded from the database.

                                  [C#]
                                  [PersistentAlias("RunningTotal(Inbound - Outbound, CreatedOn)")] public decimal Balance { get { return 0m; } }

                                  Attached is a sample project for your reference. I also updated the answer above for consistency.

                                • Kartal TURGUT 07.27.2018

                                  Thanks for your valuable support. Works perfect.