Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
UltraWinGrid and formula event timing
posted

Hi, I'm trying to perform a few operations on calculated columns in my UltraWinGrid, and they're not behaving quite as I'd hope.  What I'm trying to do is create a couple of columns that are derived from other, hidden columns, and then sort by one and autofit the header to the other.  However, at the time that I am performing these operations in my InitializeLayout event handler, I cannot get values for these columns, and I'm also having trouble finding an event that occurs with the timing I'm looking for.  I've come up with a solution that involves the layout visibly moving around before the user's eyes, and I'm trying to avoid doing that.

But let me not put the cart before the horse.  Here's a snippet of how I'm generating one of the columns, and what I'm trying to do with it:

#region Example code
            //In the middle of the InitializeLayout event handler for my grid
            //Leaving out some validation logic for my CalcManager cast
            UltraCalcManager CalcManager = grid.CalcManager as UltraCalcManager;
            CalcManager.DeferredCalculationsEnabled = false;

            ColumnsCollection bandColumnsCollection = columnsToOrderBySortedByPriority[0].Band.Columns;
            UltraGridColumn compositeDateColumn = bandColumnsCollection.Add("compositeDateColumn");
            compositeDateColumn.Hidden = true;

 compositeDateColumn.Formula = "<something complex that evaluates just fine after the first CalculationsCompleted tick>";

            e.Layout.Bands[0].SortedColumns.Add(medDescriptionColumnfalse);  //This column is assigned previous to this snippet and sorts as expected
            e.Layout.Bands[0].SortedColumns.Add(doseColumnfalse);               //This column is assigned previous to this snippet and sorts as expected
            e.Layout.Bands[0].SortedColumns.Add(compositeDateColumn, false);
#endregion Example code



The strategy that I wound up employing to try to perform this sort works, but whether I'm recalculating manually or asynchronously, the user sees the grid in its unsorted state, with null values in the cells of the column in question.  Very quickly, the cells become populated, and then the sort occurs in full view of the user - and I'm a bit concerned about the performance implications of executing this continuously:
#region Current sorting mechanism (very similar to my column fitting mechanism in my other calculated column)
        internal void EnableSortingOnCalculatedColumns(UltraGridBand bandContainingFormulaColumns)
        {
            EventHandler onCalculationsCompleted_refreshSort = (object refreshSortSenderEventArgs args=> { bandContainingFormulaColumns.SortedColumns.RefreshSort(true); };
            CalcManager.CalculationsCompleted += onCalculationsCompleted_refreshSort;
        }

#endregion Current sorting mechanism (very similar to my column fitting mechanism in my other calculated column)


Could anyone help me figure out how to get this to behave as I expect?

Thanks!

Parents Reply Children
No Data