UWP - Matrix With Grid - c#

I first would like to say that I am fairly new to UWP, and my experience with Android is probably leading some some assumptions on my end. There may be a better way about this, but so far I have been trying to use the Grid class, but it doesn't seem to work in a way that I would expect.
Basic Idea
I am trying to create a UWP application with the ability of organizing elements in a matrix, where each row and column represents some category, and whatever element that is within both row and column categories is placed in that cell. One or more elements can be listed in each matrix coordinate. An image for reference is below:
To give a more clearer/specific example, let's say the Elements were Employees, rows were Teams, and columns were disciplines (Testing, Dev, Management)
Comparing different category-types can be useful for displaying information, but this will have greater importance beyond just names, so this is only a simplified example. Also, as shown in the example, the number of rows and columns is determined by the number of categories there are for each respectively (e.g. # rows = # teams and # columns = # disciplines).
I don't have any code to show, simply because this isn't so much an error problem as it is a conceptual problem.
My Questions
How would I be able to filter what elements are bound to a cell by their Row/Column? Is this even possible?
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
How do I bind columns and rows to their respective list of categories?
e.g. whenever I add another Column Category, a new empty column will be generated.
I appreciate your help and time!

For your scenario, the better way is using DataGrid to replace.
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
You could use binding way to specific current element in which column and row, but you need to calculate before preparing data source for Grid panel.
whenever I add another Column Category, a new empty column will be generated.
If you use DataGrid, it will generate Column base on your item's new filed. Here is code sample that your could refer.

Related

DataTable columns inside columns or merged row table structure

I've had a Google but I find no answer. You know how say in MS Word, when you insert a table, you can merge the columns of one single row to create a column-less row? Or have say a main header and then more columns inside it? Like so:
Merged Row:
|Column 1|Column 2|Column 3|
|Value|Value|Value|
|Merged Row|
|Value|Value|Value|
God the text formatting is awful on this web-site...and the Header Column example:
|Main Header||Another Main Header|
|Column 1|Column2||Column1|Column2|
I'm trying to achieve this in a written DataTable in C# which is being populated by an array. But I'm interested in changing its structure as one of the above, whichever is possible/easier.
So I've created my DataTable and added normal columns and rows etc. But I'd like to create either a merged row or a main header to display. Instead of having a repeated value in a single column for the values I am getting.
Can someone please provide a quick example on how I could achieve either one of those? Because repeated value will just look ugly.
Cheers.
You're talking about displaying data in a particular way but a
DataTable has nothing to do with display. It is for storage and that's
that. How you display the data is up to you. The same data can be
displayed in innumerable different ways. In a WinForms app, one of the
most common ways to display the contents of a DataTable is with a
DataGridView. You can choose which columns to display and merge cells
in that grid if desired. In short, you're looking in the wrong place
to do what you want to do. It is a presentation issue, not a data
issue. –
jmcilhinney

Set the visibility of a column that has been grouped (single column)

I am grouping data in a grid by two different columns.
One of the columns needs to be retained as visible and the other needs to be removed from the grid.
I have set "ShowGroupedColumns" to false as it automatically handles the column chooser etc.
But I cant seem to figure out how to make the one I want to retain visible.
Is there any way, with ShowGroupedColumns set to false that I can have it grouped by column and have the column in the grid too?
Thanks
The same problem have been already discussed in DevExpress Support Center:
Display individual columns, even if they are grouped

How to get a column total in a Winforms Pivot Grid control

I need to display the percentage of each cell, of a pivot grid, column against its column total.
So far, I have been checking possible ways to get the columns totals being displayed by the PivotGrid (as I already know how to insert a computed column using expressions) but so far I haven't found a place where these values are available.
I have also considered to handle the CustomSummary or CustomUnboundFieldData events of the PivotGrid but I don't see clearly how can I get the column total from there.
Another approach I have think of is to try to use the PivotCellBaseEventArgs.CreateDrillDownDataSource to get the underlying records of the cell, but then I will not be able to get the column total, as the records returned by that method are only for a specific cell, not for the whole column.
I'll appreciate if you can point out what would be the best approach for dealing with the cell percentage against column total requirement, including any of the previous or maybe another approach I haven't think of.
Also I will be glad if you show me a way of getting the column total from the pivot grid control, if there's any way.
I finally find the way to do this so I am posting it in case anyone else need it...
There is a property on a PivotGridField that allows you to control the way the data is "summarized" (i.e. aggregated). Usually this is set to "as is" or Default but you can change this to support what is called Percentage Modes.
So I just change the PivotSummaryDisplayType, of the field that I wanted to display as percentage, to PivotSummaryDisplayType.PercentOfColumnGrandTotal and that's it.

What WPF control suits to simulate MS Excel type of sheet filtering in a dialog table?

Requirements:
The rows must be grouped to groups
There will be subtotal rows for these groups = header rows that not in datasource for actual data rows.
Sorting and filtering should be so that rows stay under their groups/headers
Every column can be used for sorting and filtering
Columns can be added and deleted
Filtering is like in Excel -> by many columns and many values for each column can be chosen as filter criteria.
Rows filtered out are not calculated in subtotal rows.
Possibly other non-data rows can be in table and naturally they are not subject to subtotal calculation / filtering.
I specially want to know is there some kind of support for filtering like this: http://cybersavvyservices.files.wordpress.com/2011/04/excel-filter-drop-down.png
It seems that DataGridView might be the control. Semi-Excel-filtering is not supported but can be implemented with
http://msdn.microsoft.com/en-us/library/aa480727.aspx
However the method described in the article is not perfect:
It relies in bound data source which might have problems when i'm having rows not part of the data source.
It seems that choosing filtering values support only single select.
Grouping the actual data rows under the non-data header rows is completely unclear
Sorting and filtering functionality with the non-data header rows could be a problem
However that's maybe a starting point because a ready made functionality does not exist.
Adding 2nd answer might result million down votes but gotta add it 'cause my previous answer does not seem to make sense.
I found an article that describes more or less the requirements stated in my orig. question:
http://msdn.microsoft.com/en-us/library/ff407126.aspx
Requirement:
-> article explains this
-> these can be added to group header by making it more complex. sums of the columns can be fetched like in article the row sum
-> default functionality
-> sorting works for all columns in article. filtering example can be extended
-> this has to be implemented. column headers can have controls for hiding a column (see my other answer to my own question in Is it possible to hide columns in WPF DataGrid when defined and bound with CollectionView?)
-> implement popup for columnheader and dynamically fill it with values in that column
-> easy to implement with a converter and binding of the ui element that shows the values in group header.
-> it can be added to bound datasource as extra row or the data can be shown in groupheader if it's only little data for each groups.

DataGridView minimal amount of rows

I'm pretty much to C# and I'm trying to create a simple network analyzer. I want to be able to see packets in a datagridview. The imagined lay-out can be compared with tools like wireshark. I would like my datagridview to always be "filled". By filled I mean that it always contains rows even if these are empty.
When starting the application for example I would like the grid to be fully filled with rows. The total height of the gridView is a multiple of the row height, so it contains enough rows so it's exactly 100% filled. When adding data however I would like that these empty rows do not count so data overwrites these empty rows, and when removed these rows return if otherwise the DataGridView would not be fully filled. I realize I might explain this a bit poorly but I'm not sure how I could try to bring across what I mean otherwise. The way Excel works would be ideal for example. You start with a full screen with empty cells, and you can add things to them. If you add more data than fits a scoll bar gets introduced to still be able to see all data. When you remove it the scrollbar becomes smaller until eventually it's not needed anymore but the cells remain shown. (even if empty)
Thanks in advance,
Arnold
-edit-
Regarding height of things: I'd probably want things to be resizable in the future. So that information could probably not be exploited.
Wrap a DataGridView with a user control to override adding and removing rows.
If you are removing a row - it must be real (not marked as "place holder" [tag?]).
and if your Count is less than IdealCount, add a "place holder" row.
If you are adding a row - if your Count is less than IdealCount, remove the last "place holder" row.
Initialize with IdealCount number of "place holder" rows.
Let the rows be sorted by a hidden column of default value 0 and a value of 1 for "place holders" or simply maintain the rows order yourself in the Add override. This way the "place holders" will always be last (and there won't be any, if Count > IdealCount).

Categories

Resources