Fix grid bug when paginator is not involved
This commit is contained in:
parent
5b05f9426f
commit
20c31cbb07
|
@ -1194,8 +1194,16 @@ class Grid(object):
|
||||||
status_map = {}
|
status_map = {}
|
||||||
checked = []
|
checked = []
|
||||||
|
|
||||||
|
# we check for 'all' method and if so, assume we have a Query;
|
||||||
|
# otherwise we assume it's something we can use len() with, which could
|
||||||
|
# be a list or a Paginator
|
||||||
|
if hasattr(raw_data, 'all'):
|
||||||
|
count = raw_data.count()
|
||||||
|
else:
|
||||||
|
count = len(raw_data)
|
||||||
|
|
||||||
# iterate over data rows
|
# iterate over data rows
|
||||||
for i in range(len(raw_data)):
|
for i in range(count):
|
||||||
rowobj = raw_data[i]
|
rowobj = raw_data[i]
|
||||||
row = {}
|
row = {}
|
||||||
|
|
||||||
|
@ -1262,6 +1270,8 @@ class Grid(object):
|
||||||
results['pages'] = self.pager.page_count
|
results['pages'] = self.pager.page_count
|
||||||
results['first_item'] = self.pager.first_item
|
results['first_item'] = self.pager.first_item
|
||||||
results['last_item'] = self.pager.last_item
|
results['last_item'] = self.pager.last_item
|
||||||
|
else:
|
||||||
|
results['total_items'] = count
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue