I have reviewed previous posts regarding removal/modification of the SortIndicator from the Column Header LabelPresenter. So far the solution seems to be centered around creating a custom control template for the LabelPresenter, however I'm hoping there is a grid-wide way for me simply collapse the existing SortIndicator area without having to recreate and hard-code all the entire IG LabelPresenter styling in my app.
Do any IG Grid / Styling gurus have any idea on how I can accomplish this?
IMHO: That dedicated SortIndicator space REALLY messes up visual alignment of column headers and makes for an overall unprofessional look :( I understand why it exists - and it's great to have the feature, but the grid would be so much better if we could collapse it when column sorting is not required - which in my case is almost always.
Thanks in advance for any help you can offer.
The SortIndicator is used to display a notification that this field is sorted. If you want to remove it and use this space, you have to either create a new control template or remove it from the existing one. I believe you know how to do this using the Default Styles, so I am pasting code that will collapse the sort indicator from procedural code:
void xamDataGrid1_Loaded(object sender, RoutedEventArgs e)
{
// Get LabelPresenter
LabelPresenter lp = Infragistics.Windows.Utilities.GetDescendantFromType(xamDataGrid1,
typeof(LabelPresenter),
false) as LabelPresenter;
if (lp == null)
return;
// Get the Parent
DependencyObject parent = lp.Parent;
int count = VisualTreeHelper.GetChildrenCount(parent);
// Get all of the LabelPresenter and their Sort Indicators and collapse them
for (int i = 0; i < count; i++)
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
SortIndicator si = Infragistics.Windows.Utilities.GetDescendantFromName(child,"SortIndicator") as SortIndicator;
si.Visibility = Visibility.Collapsed;
Debug.WriteLine(child.ToString());
}
I have a question about xamDataGrid, I have a percentage column, I want to sort it, but it's string type instead of number, so sometimes it sort wrong, do you have a better solution?
I try to sort it by data table, then bind to the user control, but I don't want to use the default sort function, and I want the triangle character display correctly, how can I do, thanks very much.
Hello Dou,
Thank you for your post. I have been looking into it and I can suggest you see this forum thread:
http://ko.infragistics.com/community/forums/t/30167.aspx
where a similar question is already discussed. Please let me know if you have further questions on this matter.
Looking forward for your reply.
In this forum thread:
http://ko.infragistics.com/community/forums/p/85598/426990.aspx
there is a sample which you can use as basis for further implementations.
I know how to do it now, and it work correctly now, thanks very much, I see the discuss as below:
http://ko.infragistics.com/help/silverlight/xamGrid_Custom_Sort.html
I'm using a datatable as the datasource then, bind the defaultview to the datasoure of XamDataGrid.
my code as below:
UI:
<igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="false" AllowResize="True" LabelClickAction="SortByMultipleFields" SortComparisonType="CaseInsensitive" CellMinWidth="50"></igDP:FieldSettings> </igDP:XamDataGrid.FieldSettings>
C# code:
this.xGridNavigation.DataSource = dt.DefaultView;
could you help me, thanks.
Thanks, but could you provide a demo on how to set the SortComparer to a class that implements IComparer, thank you very much.