OK, I'm having a heck of a time trying to find the magic incantations to make columns automatically size to their content.
Suppose I have three columns: "Size", "Mean" and "Sample Standard Deviation". I would like the Size and Mean columns to squeeze down to some minimum width, say 75 WPF pixels. But I would like the third column to expand to show the full text of the label.
"Autofit"only seems to make all columns the same width, which is not what I want.
As a bonus, I would also like to have each column automatically size to its data, so that if I entered "9999999999" in the size column, then the whole column would automatically grow larger to accommodate the new number.
Thanks,
Denny Huber
In order to do this you also have to specify a template for the grid that will be used to layout the cells in each record, as in the sample xaml below.
Note: The reason we had to take this approach instead of hanging properties off the Field is because in more complex cell layout scenarios, e.g. where cells span mutiple row/columns within each record there is not a one for one correspondence between the Field and the column(s) that contain it within the cell area of a record.
<igDP:FieldLayoutSettings>
<igDP:FieldLayoutSettings.DataRecordCellAreaGridTemplate>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</igDP:FieldLayoutSettings.DataRecordCellAreaGridTemplate>
</igDP:FieldLayoutSettings>
</igDP:XamDataPresenter.FieldLayoutSettings>
So far so good, but this makes a *very* common scenario rather complex, and if I got that right, it disallows the user to resize the column widths. My current project contains roughly 10 different grids and I'm missing a working resizing behaviour in every one of them, mainly because I want to fill the columns all available space (AutoFit is a joke, I really can't image I'll ever need equally sized columns in a real live application that provides heterogenous data). IMO there is no valid explanation why this shouldn't work like WinGrid - if AutoFit AND cell widths would work together, we had a simple solution.
Just my 0.02$
Philipp,
You make a very valid point about making a common scenario complex. We will see what we can do to improve on that in the next release. The fact the resizing doesn't work in this scenario should be treated as a bug. I would recommend submitting an issue at http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx so you can be notified when a fix is available.
Hy Joe.
I am using Infragistics 8.1. I thought using DataRecordSizingMode will solve this problem with autowidth of the columns, but it's the same. Is this problem solved in this release or will it be in the future? Does Infragistics 8.1 have a solution for this?
Thanks a lot
Nico
As recommended, I'm trying to set my initial column widths using a grid template as follows:
<igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings> <igDP:FieldLayoutSettings.DataRecordCellAreaGridTemplate> <ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="50"/> <ColumnDefinition Width="80"/> <ColumnDefinition Width="130"/> ..... etc.
This works for the intial layout, but now the user can't resize the columns.
I've tried various combinations of AllowResize="True" in the FieldSettings and DataRecordSizingMode="IndividuallySizable" in the FieldLayoutSettings and AutoFit="True" in the grid properties, etc. I haven't found a combination that works. Is there a way to set the initial column widths to something other than some uniform '*' value and still let the users resize the columns to fit (since the grid can't do it)?
If people want to autoize columns based on content then they should use the
performautofit method of the column object when initializing the grid. Don't understand why so many people have this problem.
Perhaps so many people are having this problem because we can't find any information on a 'performautofit' method or even a 'column' object in the documentation.
I can find a 'column' property which returns an int. I don't think this is the object you're talking about.
Instead of being snotty, maybe you'd care to post some sample code. Or maybe a helpful link.
ThxTom
Michel Renaud said:Are you sure this isn't for the WinForms controls? No sign of that method in the Help file, and there's no "Infragistics.Win" under WPF (unless I'm missing a DLL, but I don't think so.)
Are you sure this isn't for the WinForms controls? No sign of that method in the Help file, and there's no "Infragistics.Win" under WPF (unless I'm missing a DLL, but I don't think so.)
Whoops... So sorry. You are absolutely right. I didn't read the header of this thread at all. I just replied to that particular message. I was completely talking about the WinGrid. Hopefully it helps someone else that comes across this via Google as I did.
Chris.
Michel Renaud said: Are you sure this isn't for the WinForms controls? No sign of that method in the Help file, and there's no "Infragistics.Win" under WPF (unless I'm missing a DLL, but I don't think so.)
Inclined to agree - unable to find that namespace / class either. Good to see Infragistsics 'increased forum coverage' as promised a few months ago is paying off...
clee2005 said:I think he was referring to the PerformAutoResize method of the column object. It will resize the column to the size of the largest data. You can get the column object in a number of ways. This is the code I'm currently using : Dim uiElement As Infragistics.Win.UIElement = GetUIElementUnderCursor() mSelectedColumn = CType(uiElement.SelectableItem, ColumnHeader).Column mSelectedColumn.PerformAutoResize(PerformAutoSizeType.AllRowsInBand) I hope that helps. Chris.
I think he was referring to the PerformAutoResize method of the column object. It will resize the column to the size of the largest data.
You can get the column object in a number of ways. This is the code I'm currently using :
mSelectedColumn = CType(uiElement.SelectableItem, ColumnHeader).Column
mSelectedColumn.PerformAutoResize(PerformAutoSizeType.AllRowsInBand)
I hope that helps.
TLangFromInfragistics said: Perhaps so many people are having this problem because we can't find any information on a 'performautofit' method or even a 'column' object in the documentation. I can find a 'column' property which returns an int. I don't think this is the object you're talking about. Instead of being snotty, maybe you'd care to post some sample code. Or maybe a helpful link. ThxTom
Seeing as that person has declined to reply, can Infragistics shed any light?