mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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):
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Company
|
||||
fields = '__all__'
|
||||
|
@ -6,26 +6,7 @@
|
||||
|
||||
<h3>Companies</h3>
|
||||
|
||||
|
||||
<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 class='table table-striped' id='company-table'>
|
||||
</table>
|
||||
|
||||
<div class='container-fluid'>
|
||||
@ -48,4 +29,40 @@
|
||||
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 %}
|
@ -59,5 +59,5 @@
|
||||
sortable: true,
|
||||
}
|
||||
],
|
||||
url: 'http://127.0.0.1:8000/api/part/',
|
||||
url: "{% url 'api-part-list' %}",
|
||||
});
|
Loading…
Reference in New Issue
Block a user