Hi Team,
I am building the data dynamically for Pivot with the help of DataTable.
I want to the set hierarchies to the columns so it can be expanded or collapsed as per the level of data selected by user.
Say if 3 levels are selected from data selector, the pivot should show as below
----------------------
| Level 1 - |
| Level 2 | Level 3 |
Expanded View
| Level 1 + |
Request you to suggest some solution over it.
Sincerely,
Pratik
Hi
You can look at these posts how you can build your datasource dynamically. http://es.infragistics.com/community/forums/t/45156.aspx and http://es.infragistics.com/community/forums/t/95164.aspx
Also you can read here how to create hierarchies in your datasource http://help.infragistics.com/doc/WPF/2015.2/CLR4.0/?page=xamPivotGrid_US_Defining_Hierarchies_And_Providing_Metadata_With_FlatData.html
Thanks
Todor
Hi,
I have already created a dynamic data using datatable
Can you help me with a sample solution where I can have multiple hierarchy using code behind approach.
As the sample provided so far refer to some class and their properties. In my case I don't have as such static class, All I have is DataTable with data.
Please find the attachment of the Sample project..
Desc : Here States - California, Texas are the parents to their child cities. So it is mandatory to show them.
Expected Result : The very first column shows 0 value for California, Texas , I want to remove this column from displaying to user. But rows should not be affected
Note : I dont want to hide the column with PivotDataColumn.IsVisible, but expects permanent resolution on removing the column.
Moreover i want an Expand / Collapse button for which further level exists.
eg : VehicleType - Honda / Yamaha should have an Expand / Collapse button. On which the further level data is displayed.
Request you to help we with a solution for the both problems.
Hi Pratik,
If it's not possible to place data under Texas and California in order to remove that empty column then the only other option is to manually set the IsVisible property on the PivotDataColumn in order to hide that empty column. The column is there because empty string or null is still a valid value to pivot on so it will show in the grid. In the ResultChanged event you can use the following code:
Dispatcher.BeginInvoke(new Action(() =>{ foreach (PivotDataColumn c in pivotGrid.GridLayout.Columns) { if (string.IsNullOrEmpty(c.HeaderText)) c.IsVisible = false; }}));
Hi Rob,
Thanks very much.
The Updated Attachment of the Sample Solution give a partial resolution for my query,
Resolution found : Applying Hierarchy descriptor for dynamic data.
Issue Pending : While making the cell content to NULL , the empty rows are removed. I want the restrict column from showing empty columns, but rows should show empty rows.
I do understand that if the values given to parentData as mentioned below then the empty column can be hidden.
string[] parentData = new string[] { "California", "Honda", "CBR 1000R", null };
But unfortunately that's not possible parentData[1] cannot be set as Honda, as there can be many other Vehicle Type, I have just used Honda, Therefore
Please consider parentData as below as let me know is there any way to get rid of N/A columns but showing the empty rows mandatorily
string[] parentData = new string[] { "California", "", "", "" };
Regards,
That column shows up because the California and Texas data points have empty string values for every field except the state name field. If you give them all values except the UnitPrice field then it should get rid of that empty column and just using the existing ones. i.e.:
string[] parentData = new string[] { "California", "Honda", "CBR 1000R", null };string[] parentData1 = new string[] { "Texas", "Yamaha", "R1", null };
As for the expand / collapse button. The only way to get this to show up would be if you had a hierarchy defined in the FlatDataSource. I attached a modified version of your sample which adds a hierarchy. The hierarchy I created was VehicleType -> VehicleName.
Let me know if you have any questions.