I am trying to get the sort working correctly on this field in a xamdatapresenter. The ascending sort seems to work fine (1, 2, 3 ,4 ,5 ,6,7,8,910,11,12,13,14,15,16) but when i click the arrow for descending, the order is incorrect. It is (16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15). ?? Um, why does 16 come before everything else here? Also, is there an easy way to sort alphabetically vs numerically etc?
<igDP:UnboundField x:Name="Index" Label="#" Column="0" RowSpan="2" Converter="{StaticResource ValueConverter}"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellMinWidth="30" CellMaxWidth="30"> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock Text="{Binding Path=DataItemIndex, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IndexConverter}}" VerticalAlignment="Center"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>______________________________________________________i coudn't see most of the code when i viewed this, so here it is again below<igDP:UnboundField x:Name="Index" Label="#" Column="0" RowSpan="2" Converter="{StaticResource ValueConverter}"><igDP:UnboundField.Settings><igDP:FieldSettings ><igDP:FieldSettings.CellValuePresenterStyle><Style TargetType="{x:Type igDP:CellValuePresenter}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"><TextBlock Text="{Binding Path=DataItemIndex, UpdateSourceTrigger=PropertyChanged,Converter={StaticResource IndexConverter}}"/></ControlTemplate></Setter.Value></Setter></Style></igDP:FieldSettings.CellValuePresenterStyle></igDP:UnboundField.Settings></igDP:UnboundField>oh i included the indexconverter and valueconverters as well
Hello,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
I tried your code and it doesn't work correctly either, I get out of order and missing in "Index #'s. However; I was unaware that there was additional code in the code-behind that is doing somethign also.
can you supply a very simple sample project that does this correctly?
I have created a sample project for you using the code I have posted before. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
awesome thank you, this helps me understand a lot. However, I need to "#" column to respond to deletes etc. Your sample project does not take into account what needs to happen if a record is deleted, for example. I am unsure of what i can base the "#" off of, since I can't do like your sample and just assign it an integer myself, it needs to by dynamically linked to the collection - I believe this is why originally the Binding Path is set to DataItemIndex in the TextBlock in the original code?
someone has suggested using MultiValueConverter and MultiBinding
I have been looking into your sample and I can suggest you copy the default Styles for the CellValuePresenter and LabelPresenter in order not to lose any of the built-in functionality we provide. You can find them here: C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml file. As for the sorting I can say that it in your case it doesn’t work because it depends on the underlying object, but in your case the “#” Column does.t have underlying data. Also you can remove the sort indicator for specific Field by applying a Style to it, where this SortIndicator is removed from the Template.
Hope this helps you.
First-
I set up a Style for CellValuePresenter:
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="MyStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Label Content="{Binding Path=Index, Converter="{StaticResource IndexConverter}}"/>
.
However, the text produced is not the same as the text in other fields, do i need to somehow copy the Theme or whole CallValuePresenter style first?
Secondarily-
Thanks for your continued help. I think I'm getting closer. I found this post that is similar to what I want to do, although it does not allow the sorting, but it does provide a way to get the #(index) I am looking for:
http://news.infragistics.com/forums/t/40391.aspx
I tried to adapt it to a sample project, and it seems to work. I still have some questions:
1) How can i specify an unbound field to Sort ONLY ascending or descending or both when clicked. The sample, for some reason, only will sort ascending, but I would like to know why exactly I cannot reverse sort. It looks like it actually does try to reverse sort (the little arrow changes up/down). I even tried using a SortComparer for the field, but the objects it receives are null, so no sorting occurs. How could I make it reverse sort?
2) What is the best way to set the SortIndicator to "Hidden" for only a single unbound field?
Thanks!
Since I cannot be completely sure what is your DataSource's type and how it is organized, if this is still an issue for you, would it be possible to send me an isolated sample project and be more specific what are the results and functionalities you want to have, so I can try implement them.