Can a DataGrid dynamically mask the columns to be displayed?
Current Setup
DataGrid <--Binding--> Collection<Customer>
The type Customer has about 100 different fields defined.
Different views need to display different sets of columns (about 20 out of 100), chosen somehow dynamically, of the same Collection<Customer>.
Is there an option to dynamically mask the fields that will be displayed as columns in the DataGrid? Ideally, I want to use Infragistics' xamDataGrid, but any solution for a DataGrid will be a good starting point.
There are other similar questions out there, but they deal with either column filtering or variable number of rows.
If you are defining different views in code you could create different FieldLayouts and use the FieldLayout for the view that is needed. This would require setting the FieldLayout to be used in code by adding the layout to be used to the FieldLayouts collection.
If you are allowing the end user to define what is in the view, then you will likely want to define all possible fields and then allow the fields to be hidden or shown with the Field Chooser.
There are methods for saving and loading customizations to the fields that you can use to persist the layouts.
Related
Is it possible to have an extjs (classic) propertygrid with multiple columns for multiple data sources? We want a component where we can manage the pricelists/product matrix. Of course, we could do it with a table but this looks strange since you might only have two rows then and is far off from how the end result would look like. We are right now on extjs 6.x with the classic toolkit. How would you implement such a component based on the grid component since every column is expected to have one datatype but for a propertygrid every row column can be different in type?
I created an example of the grid you need. I overridу some celleditor methods and the headercontainer(used in propertygrid) constructor (this should not affect the other components), and I also defined a new component, the columns (additionalColumns) of which can be supplement in the same way as in the grid.
With help verticalCellTypes you can specify the same data types for the column or row
Is it possible in ExtJS to display different records from a store in different grids? I have a Store containing contact information (name, department, phone number) used to populate the contacts tab of my application. My goal is to be able to add grids elsewhere in the application that display contacts from specific departments (eg a grid for everyone in the tech department, another for everyone in the sales department). However, when I attach a filter, the filter seems to apply to the store itself, changing the display of all of the grids to the last version I try to load.
Do I need to create child grids and sync them to make this work?
No, it is not possible. The store gets filtered, not the grid itself. You do have to create multiple stores and assign a different one to every grid.
Another way to say it is that store (when used with a grid) is a ViewModel, that is, a model that is kept in sync with the view. Therefore, the same store can't be used for multiple views as you would expect.
No, but if you need a work-around, use same store for all the grids and filter store on grid's aftererender listener. But if you use these grids on tab then you need to do it on viewready event. Anyway, using same store for multiple grids will not be a good idea. Think twice before use.
I'm writing an app where i want to compare the data from two different data sources to see if there are any differences. All examples i have seen of similar functionality always place two datagrids next to each other so that you can see each row side by side.
This makes it very hard to spot differences. What i would like to do is to show the rows one above the other in agridview. That is, alternate the rows in the datagrid to be bound to one then the other datasource as a matched pair. Actually i would also like to add a check box to one row so that the pair can be selected for futher processing.
I know that the controls are very customisable but is something like this possible ? Or would i need to combine the two data sources into a single one and then bind it ?
What you're looking for is MultiBinding
This will enable you to bind multiple items and by using a converter to return a new single item. So essentially, yes, you will combine the two data sources into one inside the converter.
I have about a dozen ObservableCollections that hold objects which have dates, singles and integers. All collections are of the same length and have data added and removed at the same time. One of the ObservableCollections is the main one and is needed when referring to the others.
Is there a way to use CollectionViews to bring 2 of these ObservableCollections together in such a way that they look like one ObservableCollection having the total of all of the original columns when data bound to a datagrid and/or chart? If so does anyone have an example?
Everything I have found shows the data from both sources being brought together by adding one on top of the other in what I would call a stack of data .
Thanks
Not pretty but I have a similar application.
Have a class with 5 base properties then a variable number of fields.
The fields I put in a List.
Can bind rows to a collection but not columns.
So I use a ListView Gridview where I build up the columns in code behind.
Bind the columns to Field[0], Field[1], ...
In you case you could have base class Bclass with the base Properties and a Property List
In your List<Fields> you just iterate the properties of the List<ExtensionClass>
Clearly the List<Bclass> needs to all have List<Extension> class with the same length in every item of the binding breaks.
I know there has to be an easy way to do this, I just can't think of it. I need to display a set of notes in a WPF application. The layout for each note would be
Note Name Note Date
Note Text
Each item above exists individually in my database access layer and I just need a way to display it. In ASP, this is something I might have created a table for and then used the repeater object to dislay it multiple times (multiple notes).
Is the ListView control the best way to go about this? How would I display multiple items next to each other as above with the NoteName and NoteDate?
You could use a ListView. In this case you would declare a GridViewColumn for each column, with the appropriate DisplayMemberBinding or CellTemplate depending on the complexity of what you wanted to show.
You could also use an ItemsControl or a ListBox, with an appropriate DataTemplate. This is good for when you do not want a strict column layout (e.g. you want to show the Name and Date on one line of big bold text, and the Note Text below that in smaller italic text.)