Excel, how is the FILTER function in a Silverlight datagrid?

In Excel, there is this function for filtering column cells.

How can I implement excel function as FILTER in Silverlight Datagrid?

I ask for advice. Thanks

Aj

+4
source share
1 answer

A good question is a good feature, but not one that can be implemented in 5 minutes.

You don't want to override the rendering of the standard datagrid in any way (too much work), so you need to take a slightly different approach. One way to do this is to draw your own β€œheading” over the top of the grid β€” only the grid, with the border and stack panel, you will start. Then you need to list the visible columns of the grid and create a drop-down menu corresponding to each and add this drop-down menu on the stack. Using the simple linq operator, you can get a list of individual values ​​in each column. When the user selects a value from the drop-down list, you can then filter the grid data source using this value in the LINQ statement.

In reality, it will probably be at least a week of work to do the right thing. If you take the costs of this development and testing costs and measure it by the cost of a good set of components in which they already have built-in filtering (most major suppliers), then if you do not work at a very low rate, you will find that it’s cheaper to buy components - it’s probably also safer, as the components will be well tested and tested without errors.

Edit (some time later): I should also mention that if you want to do this in only a few columns, you can consider using a column header template. If you take this approach, although you will also have to do things like copying various animations or mouse-related transitions that may be part of the original colunm header, so you can maintain some consistency at the top of the grid. Personally, I would just go with option one and give the user the ability to filter by any of the columns.

+3
source

Source: https://habr.com/ru/post/1307966/


All Articles