We have a grid where our customers are requesting that they need to be able to select and copy out the summary values of the grid (along with cell values). We understand that this is not possible with the current version (we are using 10.3).
We have been working on some workarounds for this. The first is to use mouse/keyboard events to handle selecting logic ourselves. We have it almost working, but the code is very sluggish and buggy. We would rather not go this route if there is a better solution.
The second, which we have not played with, has to do with the ISelectableItem and the Selection Strategy methodology. I was reading the information in the following link:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2010.2/CLR2.0/html/Win_Selection_Strategies.html
From what I understand, we cannot just create a new class that inherits from SummaryValue and ISelectableItem and use these on the grid to have them able to be selected. We must implement a custom ISelectionManager that deals with selecting the next item, etc. Am I correct in this assumption?
Do you think it would be more worthwhile for us to use the Selection Strategy methodology? Do you have any examples of using this methodology on a wingrid so that we can select the summary values? We do not have a lot of time to spend on this, so if it is too much work to implement this, then we probably won't go this route.
Any suggestions or help on this would be appreciated (from anyone).
Also, do you ever plan to add this to the base functionality of the wingrid? We have submitted this request in the past but it hasn't been implemented yet.
We did prototype it and it actually works, however we decided not to put it into production code. The code is not very maintainable as you will see. If you need a quick and dirty solution though, this may point you in the right direction.
This code will definitely not be usable as is, because it is built on top of another subclass of ultragrid that we have. Another thing is that we have other draw/creation filters on our grid, so this code takes into account some of those things (we always show summary values even if we collapse a set of rows so we include these in the copy/paste values, etc.). I did not include this code but if you are curious I can post this as well.
You will also have to write a Distance function that can find distance between two points like so...
public static double Distance(Point a, Point b) { return Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2));
}
This code also depends heavily on other settings that are set in the ultragrid, and will also screw up other settings. These comments were in our code where we used this (I'm sure there's more):
"The Selected property of the grid is not correct because of the overridden behavior of grid cells. Use ReportValueSelector class instead (keep a reference to this on whatever form you use it on).
The ActiveAppearance and SelectedAppearance properties will not work as expected because of overridden behavior.
Certain properties cannot be changed on the grid. Please compile a list here for when we refactor so we can throw exceptions on the override. SelectTypeRow, SelectTypeCell, SelectTypeColumn, SelectTypeGroupByRow"
Hope this helps!
Hi, did you get how to copy summary values.
Our client is also asking for the same functionality for the project.
bbdt_travis said:I think I'm going to use the GetDescendant() method to get to the correct parent of the cells/summaries, then use recursion to retrieve them (our grid has 2 bands and can be grouped on multiple levels). I wrote a prototype and it ran quick enough that it was useful.
Yeah, that seems like a good way to do it. The reality is that checking the Type on an object is very fast, and so it iterating through collections. So even if there are a few hundred elements to go through, it should be practically instantaneous on any decent PC.
I think I'm going to use the GetDescendant() method to get to the correct parent of the cells/summaries, then use recursion to retrieve them (our grid has 2 bands and can be grouped on multiple levels). I wrote a prototype and it ran quick enough that it was useful.
When I finish with this project (still buggy and some code is specific to our case), I may post the code somewhere if other people are interested.
Hi,
You may not have to write the code to o most of the traversing of the elements. You can use the grid DisplayLayout.UIElement.GetDescendant method to walk down the tree for you.
Assuming that your grid is flat (no child bands), what I would do is find out what element contains the SummaryValueUIElements. It's probably either FixedSummaryRowUIElement or FreeFormSummaryUIElement, depending on the type of summaries you are using. You can use the Infragistics UIElementViewer Utility to find out for sure.
Once you have the containing element, you can loop through it's ChildElements collection and look for SummaryValueUIElements and get the Rect of each one.
If your grid is hierarchical or you are displaying the summaries in more than one place, then it gets more complicated and you will probably have to write your own recursive search or find a higher-level UIElement which contains the summaries.
Another option which might be a bit more efficient would be to use a CreationFilter. The CreationFilter will fire notifications every time a UIElement is created or positioned in the grid. So you could simply trap AfterCreateChildElement and watch for SummaryValueUIElement instances and store them in a List.
The problem with this is that I'm not sure how you would remove items that no longer exist in the grid. There's really no synch point for when the UIElements are removed.You might be able to deal with this by checking if the element in the list is disposed and removing it any time you check the list.
You would also have to make sure you don't add the same element to the list twice.