Hi,
We'd like to put a control in the group header area - for example a textbox to specify an offset to apply to all values for every group.
We're wondering how feasible this is within the existing infrastructure of the UltraGrid control, and if you have any recommendations on how to achieve this.
Thank you.
Hello,
Maybe one possible way to achieve desired behaviour could be if you are using CreationFilter. I have similar sample where I`m using this approach. Could you please take a look at the attached sample and let me know if you have any questions.,
Regards
Thanks Georgi for your sample, it looks promising. A few questions:
Hello Gsharm3,
gsharm3 said: Is there a way to modify the demo to include the control only in group headers?
- Yes. You could extend the IF condition in the CreationFilter. For example:
public void AfterCreateChildElements(UIElement parent) { HeaderUIElement El = parent as HeaderUIElement; if (El != null && El.Header.Group != null && El.Header.Column == null) { ButtonUIElement newButton = new ButtonUIElement(El); newButton.Text = "X"; newButton.Rect = new Rectangle(El.Rect.X + El.Rect.Width - 20, El.Rect.Y, 18, 18); El.ChildElements.Add(newButton); newButton.ElementClick += new UIElementEventHandler(newButton_ElementClick); } }
public void AfterCreateChildElements(UIElement parent)
{
HeaderUIElement El = parent as HeaderUIElement;
if (El != null && El.Header.Group != null && El.Header.Column == null)
ButtonUIElement newButton = new ButtonUIElement(El);
newButton.Text = "X";
newButton.Rect = new Rectangle(El.Rect.X + El.Rect.Width - 20, El.Rect.Y, 18, 18);
El.ChildElements.Add(newButton);
newButton.ElementClick += new UIElementEventHandler(newButton_ElementClick);
}
I`m not sure that I understand well your second point but if you change the control to TextBox, you could access the properties of this control.
Please let me know if you have any questions.
If you still have any concerns or questions I will be glad to help. If you need any additional assistance don’t hesitate to ask.
Thanks for all your grt efforts Mike.
Yes I am using single -band. I had a terrible time myself with it , but now with your valuable efforts its all sorted.
Datasource for my requirement has a pre-filtered data , so lot rows won't be an issue.
Once again thanks for your time.
Hi Deepti,
I started to write a sample for you demonstrating this, and it turned out to be a lot bigger job that I thought it would be.
Anyway, I have attached my sample here.I tried to keep all of the CheckBox encapsulated into a separate file (GroupByRowCheckBoxCreationFilter.cs) so you could hook this same code up to any grid you want. I made it work for multiple levels of grouping, also.
I made a few assumptions, like that you are only working with a single-band grid.
I am determining the state of the CheckBox in the GroupByRow by recursively looping through all of it's child rows. There are probably more efficient ways to do this by caching the states, but this code should work okay as long as you don't have a huge number of rows.
I have a similar requirement where group by column is decided dynamically an can be changed programatically. To this we need checkbox control on groupby row.
If the checkbox is checked at group level checkbox for all the rows under the group must be selected. Similarly if all the rows in a group had idividually been checked the group checkbox should also get selected.
I have applied the above samples and am able to get checkbox on header , but how to get above functionality added. Also is there way to get checkbox before group description should that we don't have to force position as description length would vary for each group.
Hello gsharm3,
Thanks for attached CreationFilter. Looking at the provided code, I think that everything is correct. Also I get your creation filter and past it in my sample and again everything works properly. So I suppose that something else in your application cause this behavior. Maybe we call our creationFilter in inappropriate moment, but I need to reproduce this behavior to be sure what is the reasons.
If you are able to reproduce this issue in a sample, I`ll be glad to research it.
Hi Georgi - we have been able to replicate the code from this prototype in our actual product, but have come across one issue - we're wondering if you might know what it could be.
Basically, in the prototype it is removing the old textboxes, and then adding new ones, which makes sense.
However, in our product, it adds the new textboxes first, and then removes the same textbox again. This is regardless of how we order the code in AfterCreateChildElements.
Do you know how we can ensure it does not remove the textboxes we've just created? It works this way in the demo, but I am not sure why it doesn't in the actual product. I've attached our full CreationFilter file - let us know if it looks correct. Note that the Remove happens first in the code, but at runtime seems to happen after the textboxes are added, removing the new textbox, and showing nothing.
Any help/suggestions would be appreciated. Thank you.