Hi,
I have UI which is having two ultra grids placed like top and bottom. Both grids are Cardview setup and if user resize the column width of the top grid i have to resize the bottom grid column width as well so that the UI looks consistence.
For the above scenario i'm trying to capture the column resize event "AfterColPosChanged" but it's not getting triggered when the grids are in cardview but in the default view it's triggered.
Please help me on subscribing the appropriate event for column resize event in cardview or an approach to achieve it.
Regards,
Sundaram
Hello ,Mee
Thank you for Posting. In the grid cardview mode when you are talking about resizing the column width I am sure you are talking about adjusting the Width of the card?
You can't actually resize the columns in CardView, because the columns are displayed as rows, and AfterColPosChanged event is specific to the grid column repositioning/resizing .
Looking into API I didn't find any specific event fire when we change the card width but you can workaround by using PropertyChanged event .Something like this:
private void UltraGrid1_PropertyChanged(object sender, Infragistics.Win.PropertyChangedEventArgs e) { var trigger = e.ChangeInfo.FindPropId(Infragistics.Win.UltraWinGrid.PropertyIds.Width); if (null != trigger && trigger.Source is UltraGridCardSettings) { Debug.WriteLine("Card Width Changed!"); } }
The downside of that approach is that this event fires any time any property in the grid changes for any reason, So it might slow down the app and cause slow performance but again there is no specific event to handle this.
Let me know if you have any question.
Regards,Divya Jain
Hi Divya Jain,
Thank you for your quick response.
Yes, I mentioned about adjusting Width of the card.
I did further investigation like creating a simple sample application as per my requirement and subscribed all the events.
When i change the width of the card no events are fired except the one which you suggested (PropertyChanged).
As you mentioned it's is fired for any property changes on the grid.
So i thought to use an other approach to subscribe the "SubObjectPropChanged" event for the CardSettings class
like below. i think this will improve in performance. Please let me know your input on this approach.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { foreach (var column in e.Layout.Bands[0].Columns) { column.Band.CardSettings.SubObjectPropChanged += column_SubObjectPropChanged; } } void column_SubObjectPropChanged(Infragistics.Shared.PropChangeInfo propChange) { var trigger = propChange.FindPropId(Infragistics.Win.UltraWinGrid.PropertyIds.LabelWidth); if (trigger != null) { //Do the action for the CardSettings width changes. } }
You are correct that the PropertyChanged event of the grid will fire any time any property on the grid changes. Although there are certain exceptions - this event does not fire for properties of the row or cell because those would be very inefficient. But you are right to be concerned about performance here.
Your approach of using SubObjectPropChanged on the CardSettings is a good idea. But your implementation has a problem. The Band property of the column is a backward pointer. So you are getting the band (e.Layout.Bands[0]) and then looping through every column of that band, then getting the Band from the column and hooking the event. So you are essentially hooking and re-hooking SubObjectPropertyChanged on the SAME CardSettings instance once for each column in the band, and there's no reason to do that. You only need to hook it once:
e.Layout.Bands[0].CardSettings.SubObjectPropChanged += column_SubObjectPropChanged;
Also... I'm a little confused about what property Id you should be looking for here. Divya's example used Width and yours is using LabelWidth. If LabelWidth is also changing, then that's fine and I don't think it matters. But just out of curiosity, are you setting the RowLayoutStyle on the Band here? If you are, and your band is using RowLayouts, then you might be able to utilize the AfterRowLayoutItemResized event, instead of SubObjectPropChanged. But if you are not already using RowLayouts, it's probably not worth switching, since it would require a lot of changes to your existing code.
Hi Mike,
As i mentioned earlier i was looking for the LabelWidth that is working fine for one of my requirement.
the other one which i'm looking for is the ColumnWidth changes, I can use the same approach for getting the column width changes but in have to identify which column is updated so that in the other grid i can update the specific (i.e. the same position ) column width.
Is there any way to identify which column is changed (or) the index of the column details.
Thank you for your quick reply. Now i got the implementation of cards width update and when i change the card width in the CardSettings it is updating for all cards.Thanks again.
There is no column. In CardView, columns and rows are reversed. So there is no column being resized here. If anything you would be resizing a row. But in the default case, that's not true, either, since ALL of the cards are resized.
If there was a single row or column involved, then you can probably find it using the propChange passed into the event args. propChange has a property on it called Trigger. The Trigger property returns the propChange for the subObject that triggered the changed. So if you were to resize a single column in a non-CardView grid, the ultimately trigger would be the Width property on the Row and that would bubble up to the band and then to the layout and then to the grid.
But like I said, unless you are somehow changing your CardSettings in such a way that each card has a different width, there is no sub-object here. You are essentially just setting a single property that affects ALL cards.