Hi
Attached SummaryCellsTextOverlap.zip has source code files and also has GroupTextOverlap.PNG for existing and expected results.
I am trying to do sum aggragation on ID and group by on Abbreviation colums. Right now in result, Abbreviation group by text is overlaping other summary cells (IDName and ID).
Is there a way to fit the group by text in the first cell?. Check GroupTextOverlap.PNG for expected result.
Can you modify the attached source with solution and post in this.
Thanks in advance.
Hello,
The GroupBy header that contains the column value is not limited to the width of the column. What you can do is to implement IGroupByEvaluator interface and customize the group header any way you like.
I have modified your project (attached). I added a class named "CustomGroupByEvaluator", and in XAML find my changes denoted as:
<!-- CHANGES start:-->
<!-- CHANGES end:-->
I included some comments, and if you have any other questions feel free to ask.
Sam
Thansk for the response.
I am looking for following.
Group by cell should show text which fits (Remaining text can be truncated) in.
On resisze of Group by Column, group cell should show text which fits (Remaining text can be truncated) in.
Check the attached image for expected result.
Let me know if this is not clear.
Thanks for the response.
I am expecting the result as in screen shot.
In screen shot truncast text was result using image editor (to show for the result that I am expecting).
Issue I am having that Group by text is being overlapping on other summary cells text (ex: Abbreviation column group by text is overlapping on ID column summary data
Is there a way we can truncate the text based on width and on column resize it should show the text that fits in the available width?.
For sample, please use the code attached in previous posts.
Hi,
You can use the SizeChanged event of the label presenter with Style/Setter and then retrieve the GroupByRecord and change the description. In your code you already had a logic that you used in the Grouped event. You can use similar logic in SizeChanged event. Here is the code example to achieve it.
// Style
<Style x:Key="lp" TargetType="{x:Type igDP:LabelPresenter}">
<EventSetter Event="SizeChanged" Handler="OnColumnSizeChanged"/>
</Style>
// Field settings
<igDP:Field Name="Abbreviation">
<igDP:Field.Settings>
<igDP:FieldSettings LabelPresenterStyle="{StaticResource lp}"/>
</igDP:Field.Settings>
</igDP:Field>
// Handling event. This event will get raised every time the columns are resized.
void OnColumnSizeChanged(object sender, SizeChangedEventArgs e)
{
foreach (var item in xamDataGrid1.Records)
GroupByRecord dr = item as GroupByRecord;
if (dr != null)
if (dr.GroupByField.LabelWidthResolved < 99)
item.Description = "Here is GroupBy...";
}
else
item.Description = "Here is GroupBy record's description";
Let me know how this worked for you.
Thank you,
I tried to add the code in attached sample (inside zip) and able to achieve for First group by. I had to use tag (to maintain old value) to fit the text.
Let me know this solution is right way of implementing.
Also I would like this truncate logic to applied on Second group by (third, fourth so on). Check the "GroupTruncate.png" file in attached zip for the result that I am expecting. I did tried a bit and had no luck on this. Can you modify the attached source and upload back.
For the nested levels of GroupBy records I would use a recursive logic to retrieve the child records and apply the same concept of truncating the labels. As far as maintaining the initial value, Tag is fine or a string field in code. Here is an example of truncating the labels in nested GroupBy records.
1. In the event the first call to TruncateGroupByLabels() method is for the first GroupBy record.
2. After that I call a method for recursive execution using the child records.
foreach (Record item in xamDataGrid1.Records)
// Truncate the labels on GroupBy records
TruncateGroupByLabels(item);
// In case the GroupBy records have nested GroupBy records
if (item.HasChildren)
GetChildGroupByRecords(item);
// Execute recursively to retrieve all GroupBy records and set the labels
public void GetChildGroupByRecords(Record record)
foreach (Record rec in record.ViewableChildRecords)
if (rec.HasChildren)
GetChildGroupByRecords(rec);
TruncateGroupByLabels(rec);
public void TruncateGroupByLabels(Record record)
GroupByRecord groupRec = record as GroupByRecord;
if (groupRec != null)
if (groupRec.GroupByField.LabelWidthResolved < 99)
record.Description = "Truncated...";
record.Description = "Here is GroupBy record's description";
I hope this helps. Let me know if you have any questions.
Now I am able to do truncate for nested group by. Code is using group value (instead of tag value). Attached zip has the modified code (might be helpful for others) and result snapshot.
Thanks. That was helpful.
I did not realize that truncate is firing even group by not exist. I've put in code to fire only if group by exist.
Also as we are resetting description in truncate, we can set " " for blank description to avoid "(item)" or "(items)" text. Now I can remove ContentControl_Loaded code and comment Description = " " code in AbbreviationSortComparer. (this will gain some performance).
Thank you for your post. I have been looking into it and the code you have provided and I modified it and created a sample project for you with the functionality you want. Basically I moved the logic for truncation in a separate function and called that function after the new data source is loaded. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
How to fire the column resize when grid datasource got new data?
Attached file has the code and image (for expected result) files.
1. Run the code. This will load grid data.
2. Group by Abbreviation column.
3. Group by records will have truncated data (with ...) to fit in cell. Data will truncate/expand when we re-size the Abbreviation column.
4. Hit "Load New Data" button (which is on top) to set new data to the grid without changing the grid columns or layout.
5. Now grid has new data but the Group by Row text is not truncating (as the column re-sizing not firing).
Can you make changes to the code and upload back with the fix.