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

Bootstrap.html template doesn't include attrs #335

Closed
ralgozino opened this issue May 31, 2016 · 10 comments
Closed

Bootstrap.html template doesn't include attrs #335

ralgozino opened this issue May 31, 2016 · 10 comments

Comments

@ralgozino
Copy link
Contributor

ralgozino commented May 31, 2016

Hello there!

I was trying to use the bootstrap.html table template, but I found that trying to add a class to the table, let's say the "small" class setting the attr in the Meta class doesn't end added in the final html.

Let me know if I can help.

Cheers!

@jieter
Copy link
Owner

jieter commented May 31, 2016

@ralgozino You are right, thanks for reporting.

If you are willing to fix it, you are very welcome. If you do, you might also want to have a look to some other issues with the templates I made an issue for today, #334.

@jieter
Copy link
Owner

jieter commented Jun 1, 2016

The problem with the attrs for the bootstrap template is that we need to add some classes specifically for the template. If you add attrs = {'class': 'foo'} to Table.Meta, it will currently render to something like

<table class="table table-bordered table-striped" class="foo">

which doesn't work. Maybe we should be able to add attrs for a certain class in the template, which would require a custom tag as passing arguments to attrs.as_html is not possible in Django templates.

@ralgozino
Copy link
Contributor Author

Hello @jieter ! I'm starting my honeymoon this saturday, so I'm short of time lately and be out of town for two weeks. I'll give it a shot in my return and try to fix this.

@jieter
Copy link
Owner

jieter commented Jun 2, 2016

@ralgozino good for you, enjoy!

@ralgozino
Copy link
Contributor Author

ralgozino commented Jul 15, 2016

The problem with the attrs for the bootstrap template is that we need to add some classes specifically for the template. If you add attrs = {'class': 'foo'} to Table.Meta, it will currently render to something like
<table class="table table-bordered table-striped" class="foo">
which doesn't work. Maybe we should be able to add attrs for a certain class in the template, which would require a custom tag as passing arguments to attrs.as_html is not possible in Django templates.

What about doing the same as the default theme, I mean, you have to add the {'class':'paleblue'} in order to it to work, but with bootstrap you'd have to add {'class':'table table-striped etc...'}

This way would be consistent with the "paleblue" theme in my opinion.

@ralgozino
Copy link
Contributor Author

ralgozino commented Jul 19, 2016

@jieter I have a working copy with the previous proposal. I can send a pull-request if you want, let me know what you think.

I can probably do #334 also.

Cheers!

@jieter
Copy link
Owner

jieter commented Jul 19, 2016

Would appreciate that!

@jieter
Copy link
Owner

jieter commented Aug 17, 2016

@ralgozino any news on opening the PR? Looking forward to it.

ralgozino added a commit to ralgozino/django-tables2 that referenced this issue Sep 6, 2016
@ralgozino
Copy link
Contributor Author

I've just sent the PR, first time ever so please excuse if it isn't righr. Please let me know what you think.

Sorry for the delay!

@ralgozino
Copy link
Contributor Author

ralgozino commented Sep 12, 2016

@jieter with the boostrap.htlm I propose setting by default the "table" class and letting the user custimized it further, like this:

<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />

And then, if the user wants an striped bootstrap table, he should add:

attrs = {'class':'table table-striped'}

With the paleblue theme, I'm not sure.. maybe we should use the template attribute like with bootstrap?

@jieter jieter closed this as completed in 2bf8fd3 Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants