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.
Hi,
bbdt_travis said: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?
Yes, I beleive that is correct. Implement ISelectableObject would not do you much good unless the SelectionStrategy was updated to know how to deal with those objects. This is probably possible, theoretically, but it would not be trivial to do and unless you have access to the Infragistics source code for the exist SelectionStrategies to use a guide, it would be nearly impossible.Even with the source code, it will probably be very complex and I would not recommend it, especially if you do not have a lot of time.
If I were going to implement this, I'd probably do it manually rather than using the SelectionStrategy approach. But even then, it's not going to be a trivial task.
It might be easier if I knew what kind of assumptions you can make here. What exactly are the requirements?
For example:
In the simplest cases with a flat grid and no OutlookGroupBy, and where users need to be able to select a summary cell (or multiple summary cells) or the entire summary row at once, the implementation would be pretty easy.
In a complicated case with multiple levels of hierarchical data and OutlookGroupBy where you need to select Summary cells/rows in addition to data rows/cells, it will be much more complicated and difficult.
We only need to get this to work for one grid within the application, but unfortunately it has a lot of the functionality turned on and has most of the requirements you listed.
The grid itself has 2 bands, and we are only allowing the user to select cells within the 2nd child band. The parent band is just used to logically separate the data. We are using OutlookGroupBy; they can choose to group by 3 different columns.
Users should be able to select summary cells and/or data cells at the same time. So it would behave exactly like if the summary cells were able to be selected/activated. I think we can get away with disabling the row selection and summary row selections if we can get the other functionality to work.
Currently, we are capturing mouse events and redrawing a rectangle when we enter new cells, and whatever data cell or summary cell is in the rectangle, we are setting the selected appearance. If we land on a data cell or summary cell, we set active appearance. We don't necessarily care if the Selected object is useful since we are creating our own clipboard string.
We have methods that recurse through the grid (regardless of group-by, etc.) to find all cells within a certain rectangle, and also given a top-left and bottom-right cell (or top-right and bottom left) will find all cells in that rectangular region.
The main issue we are having right now is when we need to start scrolling. If the user lets go of the mouse and we are outside of the grid, we cannot figure out how to find the cell that is closest to the mouse location that is within the drawn area of the chart. We have tried many things with no success.
Another issue is with Shift + arrow keys. Since summary values do not activate, when we hit shift+down arrow to try to go to the summary value, it skips over it and goes to the next row, selecting both. We will probably just have to handle this manually, just haven't looked at it yet.
The last big issue is refreshing the selected cells correctly. We obviously don't want to redraw the chart every time the user is holding the left mouse down and moves the mouse. This will probably just take some time to play with and find the states where the grid should redraw.
I think it's just going to take some dev time to figure this out. I mostly wanted to make sure we weren't reinventing the wheel here.
If you have any hints as to the first issue (figuring out the cell closest to the mouse location within the drawn area of the grid), that would be great.
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.
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.
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.
Hi Mike,
Has this functionality been included in Infragistics version now?
I am looking for a simpler solution to copy summary values.
Thanks,
Sonam Rastogi
Hello Sonam,
After some research, the "Ability to select and copy summary values" has been determined to be a new product idea. I have sent your idea directly to our product management team.
Our product team chooses new ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested features, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time.
Your reference number for this product idea is PI12090055.
If you would like to follow up on your request at a later point, you may contact Developer Support management via email. Please include the reference number of your product idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
Thank you for your request.
A solution to copy summary values is :-
1. Give context menu on grid having copy option
2. Handle mouse down event on the grid and check for right click, if action is 'Copy', then get element which is being clicked and find out text of the clicked element, then set it to clipboard. Refer below code:-
UIElement objClickedElement = ultraGrid.DisplayLayout.UIElement.ElementFromPoint(new Point(mouseEventArgs.X, mouseEventArgs.Y));
gridSummaryText = ((TextUIElement)objClickedElement).Text;
Clipboard.SetText(gridSummaryText);
Thanks
Hi Sonam,
You can't trap for clicks on the checkbox - the grid doesn't create the summary when you click the checkbox, anyway. The summary isn't created until you close that dialog. So you could trap the AfterSummaryDialog event of the grid, and make any adjustments you needed.
Thanks for raising this as a new product idea.
Please let me know if it is possible to hide summary values row (Sigma symbol still visible) and we can handle 'Summary Value Changed' event on click of 'Sum' checkbox under 'Sigma' button to show a information in either a messagebox or an extra row added at runtime in existing grid.