Hi,
I want to build a feature where we have expander over the cells of xamdatagrid, This expander should work in such that way that when we hit that expander all the cells beneath that expander should collapse/expand (The cells will be given a key so that the expander comes to know which cells it has to collapse/expand). So basically the expander has to work across different rows of xamdatagrid but for just one column.
The expander has to be smart enough to
1) identify if the other columns has more rows than the one in expander in that case the collapsing of expander should work in such a way that the data under the expander gets invisible rather than the cells being collapsed
2) If the there are more cells under the expander it should collapse itself in such a way that it gets collapsed uptil the adjacent coluimns doesnot has data and the point where the other columns contain data then the data under for those cells get invisible rather than those cells being collapsed.
I think this feature is not currently available with xamdatagrid but it will be great if someone can confirm this and is there any possibility that we can get this feature in the near future.
Thanks
Sumeet
Hello Sumeet,
I am just checking if you have any other questions.
In order to have expander only for some of the cells you could use trigger and check if it meets certain conditions. In the code below I checked if the name is “Name 0” and if so, I display a TextBlock in the cell instead of an Expander.
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander Grid.Row="0" Header="ExpanderHeader" Height="Auto" VerticalAlignment="Top">
<igDP:XamDataGrid x:Name="xgrid1"
BindToSampleData="True"
GroupByAreaLocation="None">
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False" CellClickAction="SelectRecord"/>
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings RecordSelectorLocation="None" LabelLocation="Hidden" AddNewRecordLocation="OnTop" AllowAddNew="True"/>
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.Name}"
Value="Name 0">
<TextBox Text="Cell without expander"/>
</DataTrigger>
</Style.Triggers>
</Style>
There is no easy way to display fields with different number of cells in it. You could try to use a grid for the fields where you want to have two rows of data like 30 and 35 for the Age field.
I hope this will help you.
Thanks for your reply , this sample doesnt completeely sute my requirement as
1) As an Example the Age column for one Name we can have multiple Age, So I need to represent two subrows in Age say Name 0 cane have age 30 and 35, so here 30 needs to be represnted next to text "Expandable Data" and 35 needs to be represnted next to "John Smith ...." when the expander is expanded.
In case when the expander is collapsed 30 need to be represnted next to text "Expandable Data" and 35 needs to be represnted below 30 and in this case there needs to be additional space/row below expander which should be blank.
2) The field Expander field has got all the cells with in it with expander , I can have a situtation where half the cell is required without expnader and half of it with in expnader, As an example I have value "Name 1 Human Resources 100 name1@abc.com" which will be above the expander and below this the expander starts.
Thank you for all the details and the screenshot. I made a simple project representing this behavior where I used Expander for the CellValuePresenter style of the unbound field. I have added a XamDataGrid in the expander and hide the group by area, the recordSelector and the labels of the columns. Feel free to let me know if this helps you in resolving your issue.
(please consider there will be grid lines for each individual row , The grid lines are not present in the screen shot i.e. the row for value 15 has a line starting from the columns where IE is and ends at the last column where we see value of 20)
Please have a look at the screen shot, Here the columns are
1) IE
2) Ireland
3) Accounts(17) with the "^" icon which has mutiple rows
4) Value 20 and so on
Now Accounts is a column which has a expander when this expander is collapsed we need to take care
a) it has collapsed all the cells/rows underneath uptill the next column which has second highest row, and for other cells/subrows it should make them appear but with invisible data
b) if any other column has more rows than Account we just need the data in account to be invisible rather than collapsing the rows
Please bear in mind the other columns can also have mutiple rows within (even more than what we see for accounts) but without expander.
The logic I have thought to implement is the first row will have values IE, Ireland, Acccounts(17) with "^" icon, 20 .....,
The second row will have data all the cells blank apart from accounts column some like "","",15 (15) XRACCNT01 (This will be implemented by modifying cell value preseneter), "", ""....
But with this approach expanding and collapsingindividual column becomes a problem as it has to take care of the other columns as well in doing so
The reason we are trying to put expander over the cells is we need to select individual rows in the expander,
There is a way to put expander under the cell value presenter and put all the data under that expander this provides me with all the functionalities but it doesnt let me select individual row within the expander as it is part of the cell.