mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Bootstrap table to company list
This commit is contained in:
parent
1899d8f3e9
commit
be0797c6e6
@ -5,6 +5,8 @@ from .models import Company
|
|||||||
|
|
||||||
class CompanySerializer(serializers.HyperlinkedModelSerializer):
|
class CompanySerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Company
|
model = Company
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -6,26 +6,7 @@
|
|||||||
|
|
||||||
<h3>Companies</h3>
|
<h3>Companies</h3>
|
||||||
|
|
||||||
|
<table class='table table-striped' id='company-table'>
|
||||||
<table class='table table-striped' id='company-table' data-sorting='true' data-filtering='true'>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for company in companies %}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'company-detail' company.id %}">
|
|
||||||
{{ company.name }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>{{ company.description }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
@ -48,4 +29,40 @@
|
|||||||
follow: true
|
follow: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#company-table").bootstrapTable({
|
||||||
|
sortable: true,
|
||||||
|
search: true,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'pk',
|
||||||
|
title: 'ID',
|
||||||
|
visible: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: 'Company',
|
||||||
|
sortable: true,
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(value, row.url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'description',
|
||||||
|
title: 'Description',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'website',
|
||||||
|
title: 'Website',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
if (value) {
|
||||||
|
return renderLink(value, value);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
url: "{% url 'api-company-list' %}"
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -59,5 +59,5 @@
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
url: 'http://127.0.0.1:8000/api/part/',
|
url: "{% url 'api-part-list' %}",
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user