Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to change columns reactively? #31

Open
francisbyrne opened this issue May 27, 2014 · 3 comments
Open

Is there any way to change columns reactively? #31

francisbyrne opened this issue May 27, 2014 · 3 comments
Labels

Comments

@francisbyrne
Copy link
Contributor

@austinrivas I'm wondering if there would be any way to modify the table columns reactively. For example, I'd like to be able to change which columns are shown based on a checkbox, to switch between e.g. percent vs absolute performance.

Something like the below, where Session.get('displayPercent') is linked to a checkbox, so the change column switches data source when it is checked and unchecked.

columns: [{
          title: "symbol",
          data: "symbol"
        },{
          title: "price",
          data: "price"
        },{
          title: "change",
          data: function() {
            return ( Session.get('displayPercent') ? 'changePercent' : 'change' );
          }]

Outside of my specific use-case, I think it would be a useful feature for doing things like selecting columns to show in a table, etc.

Would there be any way to achieve this?

@gjolund
Copy link
Contributor

gjolund commented May 29, 2014

@francisbyrne I have been using the DataTables colVis plugin for these types of modifications, but I can see why you would also want external access.

I should be able to make all of the datatables configuration options reactive in the same way as the query, I'll try to get something working in the next few days.

@francisbyrne
Copy link
Contributor Author

I worked out that you can actually just do this in the mRender; it's a bit of a hack but works fine:

mRender: function(data, type, full) {
            return Session.get('displayPercent') && full.changePercent || data;
          }

@gjolund
Copy link
Contributor

gjolund commented Jul 1, 2014

What makes you feel like its a hack? From my perspective that is the intended use of the mRender callaback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants