question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: How can I programatically add columns with filter?

See original GitHub issue

Hi! This project is great! Thanks a lot!

I have a question though. I’m using DataGridFilter in conjunction with BindableColumns from this post on StackOverflow to be able to add columns dynamically when utilizing MVVM. This means I’m adding columns programaticaly (in the ViewModel) like this:

public ObservableCollection<DataGridColumn> Columns { get; set; }
...
Columns.Add(new FilterDataGrid.DataGridTextColumn()
{
    Header = "Name",
    IsColumnFiltered = true,
    Binding = new Binding() {...},
    HeaderTemplate = ???,
});

I guess I have to fetch the HeaderTemplate, but is that possible from a viewmodel? Can I add a reference to the DataGridHeaderTemplate resource in my application resources somehow maybe?

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ottossoncommented, Feb 18, 2022

hmm, that’s true. I’ll have to think about this. There must be a way. I’m surely not the first person to have this need…

0reactions
macgilecommented, Feb 18, 2022

Yes, but you will have to do it yourself. On the other hand I’m not sure if it works, by adding the columns as you want to do it, the ItemsSource property will not be filled, the added columns will be detached from this property, as if they were isolated from all the mechanics internal to the datagrid.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery Tablesorter Add Column with Filters
I have seen this question: Adding columns dynamically to a table managed with jQuery's tablesorter - which recommends that I remove and recreate ......
Read more >
Dynamically Add Columns using Filter
Suppose you have 20 columns in a sheet & you want to add specific number of columns based on the selection in the...
Read more >
Solved: Dynamically Add Columns, Filter Excel Dataset and
Dynamically Add Columns, Filter Excel Dataset and Group By in Datatable ... You can collect this or use it in a gallery filter....
Read more >
How to set filters to column programmatically? in UI for WPF
Hi, Attach to RadGridView's AutoGeneratingColumn event and then in the event handler you will have e.Column.ColumnFilterDescriptor which is used ...
Read more >
[OutSystems Data Grid] Programmatically Add Filters to ...
Hello, first of all this component is very useful! Thank you for putting this together. Is it possible to apply filters to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found