djk2 / django-tables2-column-shifter

Simple extension for django-tables2 can dynamically show or hide columns. Using JQuery, Bootstrap 3, Bootstrap 4, Bootstrap 5 and Django >=1.9
BSD 3-Clause "New" or "Revised" License
21 stars 8 forks source link

Using Issue #23

Closed BrennanCode1 closed 3 years ago

BrennanCode1 commented 3 years ago

I followed the starting guide and for some reason i cannot get the drop down menu to work.

Django==3.1.4 django-bootstrap4==2.3.1 django-tables2==2.3.4 django-tables2-column-shifter @ git+https://github.com/djk2/django-tables2-column-shifter@97b9516945e50b49c58dcc18128553e487fe5844

heres what im using as my requriments am i missing someting?

djk2 commented 3 years ago

Hi. I will check it and I will let you know.

djk2 commented 3 years ago

Hi.

For deeper analize I need more details.

I will what I can do to help you.

BrennanCode1 commented 3 years ago

Hi super sorry about being vague, updated the install to pip install, here is all the code im using if i can give you anything else let me know! My issue is whenever im clicking the visible columns drop down nothing comes down it doesnt open a menu simply nothing happens. Here is my tables.py: from django_tables2_column_shifter.tables import (

ColumnShiftTableBootstrap4, # If you user bootstrap3

) class MyModelTable(ColumnShiftTableBootstrap4): class Meta: model = Allocations

Here is my views.py def simple_list(request): queryset = Allocations.objects.all() table = MyModelTable(queryset) return render(request, 'WebAPP/displaythree.html', {'table': table})

Here is my displayhtml {%extends "WebAPP/base.html"%}

{% load render_table from django_tables2 %} <!DOCTYPE html> {%block body_block%}

List of persons
<body>
    {% render_table table %}
</body>
    {%endblock%}

here is my base.html with the code your read me instructured me to use and place <script src="{% static "jquery.min.js" %}"> {# require #} <script src="{% static "bootstrap/js/bootstrap.min.js" %}">

  <script
      type="text/javascript"
      src="{% static "django_tables2_column_shifter/js/django_tables2_column_shifter.min.js" %}">
  </script>

placed in the body !

Any help you can provide would be awesome! I am recieiving no errors in the console just the drop down isnt working properly!

djk2 commented 3 years ago

After very quick review of your code:

Bootstrap version

I'm not sure which version of bootstrap you use. In snip of template I see:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

This code indicate that you use botstrap v3, but on the beginning of this issue you wrote django-bootstrap4==2.3.1

Inheritance

class MyModelTable(ColumnShiftTableBootstrap3): class Meta: model = Allocations ...


* If you use **bootstrap4** your table class has to inherit from `ColumnShiftTableBootstrap4` like below:

from django_tables2_column_shifter.tables ColumnShiftTableBootstrap4

class MyModelTable(ColumnShiftTableBootstrap4): class Meta: model = Allocations ...



I foud small mistake in README file, and I guess that you copied code from documentation where is a small gap. 
Obviously I will fix README.rst file. 

### JS. Scripts 
If you use bootstrap3, the current js script should be enought.
But
Draw attention to fact that from version boostrap4.1
a `Popper.js` is required. 
This is a dependency for bootstrap4 JS scripts. 
Below more details: 
https://getbootstrap.com/docs/4.0/getting-started/javascript/#dependencies

Above is critical for dropdown functionality. 
Without `Popper` the part of scripts from bootstrap won't be work.
Here you can see how I implemented template for demo project using bootstrap4:
https://github.com/djk2/django-tables2-column-shifter/blob/master/testproject/testproject/templates/testproject/test_bootstrap4.1.3.html

And one small remark. 
For future, it will be much more easier read of you code,
when you try format code in GitHub issue. 
You can use triple \` char to mark a piece of code or 
just use a function `insert code <ctrl+e>` of builtin editor of GitHub.

If you have any more question, feel  free. 
djk2 commented 3 years ago

I fixed documentation, I hope that now it is more clear.