Skip to content

Commit e690b5d

Browse files
committed
Fixed a bug regarding rowCount and improved visualization
1 parent e1b9a3d commit e690b5d

13 files changed

+108
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.9.6-rc2
4+
- Fixed a bug regarding rowCount
5+
- Improved visualization generally
6+
37
## 0.9.6-rc1
48
- Prevent click event on active pagination item
59
- Added refresh button

bootgrid.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"accessibility",
1515
"bootstrap"
1616
],
17-
"version": "0.9.6-rc1",
17+
"version": "0.9.6-rc2",
1818
"author": {
1919
"name": "Rafael Staib",
2020
"email": "me@rafaelstaib.com",

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"accessibility",
1414
"bootstrap"
1515
],
16-
"version": "0.9.6-rc1",
16+
"version": "0.9.6-rc2",
1717
"authors": [
1818
{ "name": "Rafael Staib", "email": "me@rafaelstaib.com", "url": "http://www.rafaelstaib.com" }
1919
],
-12.8 KB
Binary file not shown.
12.9 KB
Binary file not shown.
-11.4 KB
Binary file not shown.
11.6 KB
Binary file not shown.

build/jquery.bootgrid.js

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Bootgrid v0.9.6-rc1 - 05/28/2014
2+
* jQuery Bootgrid v0.9.6-rc2 - 05/28/2014
33
* Copyright (c) 2014 Rafael Staib (http://www.jquery-bootgrid.com)
44
* Licensed under MIT http://www.opensource.org/licenses/MIT
55
*/
@@ -52,7 +52,7 @@
5252
{
5353
var request = {
5454
current: context.current,
55-
rowCount: options.rowCount,
55+
rowCount: context.rowCount,
5656
sort: context.sort
5757
},
5858
post = options.post;
@@ -167,9 +167,17 @@
167167
tpl = options.templates;
168168

169169
instance.loading = $(options.templates.loading.resolve(getParams(context)));
170-
instance.header = $(tpl.header.resolve(getParams(context, { id: element._bgId() + "-header" })));
171-
instance.footer = $(tpl.footer.resolve(getParams(context, { id: element._bgId() + "-footer" })));
172-
element.addClass(css.table).before(instance.header).after(instance.footer).after(instance.loading);
170+
element.addClass(css.table).after(instance.loading);
171+
if (options.navigation & 1)
172+
{
173+
instance.header = $(tpl.header.resolve(getParams(context, { id: element._bgId() + "-header" })));
174+
element.before(instance.header);
175+
}
176+
if (options.navigation & 2)
177+
{
178+
instance.footer = $(tpl.footer.resolve(getParams(context, { id: element._bgId() + "-footer" })));
179+
element.after(instance.footer);
180+
}
173181

174182
renderTableHeader(element, options, context);
175183
}
@@ -210,8 +218,8 @@
210218
var $this = $(this);
211219
if ($this.text() !== currentKey)
212220
{
213-
// todo: sophisticated solution needed for figuring out which page is selected and if applicable to reset the current page
214-
context.current = 1;
221+
// todo: sophisticated solution needed for calculating which page is selected
222+
context.current = 1; // context.rowCount === -1 ---> All
215223
context.rowCount = +$this.attr("href").substr(1);
216224
loadData(element, options, context);
217225
}
@@ -267,13 +275,22 @@
267275
if (options.navigation !== 0)
268276
{
269277
var instance = getInstance(element),
270-
end = (context.current * context.rowCount),
278+
selector = getSelector(options.css.infos),
279+
header = instance.header.find(selector)._bgShowAria(context.rowCount !== -1),
280+
footer = instance.footer.find(selector)._bgShowAria(context.rowCount !== -1);
281+
282+
if (context.rowCount === -1)
283+
{
284+
return;
285+
}
286+
287+
var end = (context.current * context.rowCount),
271288
infos = $(options.templates.infos.resolve(getParams(context,
272-
{ end: end, start: (end - context.rowCount + 1), total: context.total }))),
273-
selector = getSelector(options.css.infos);
289+
{ end: (end > context.total) ? context.total : end,
290+
start: (end - context.rowCount + 1), total: context.total })));
274291

275-
replacePlaceHolder(options, instance.header.find(selector), infos, 1);
276-
replacePlaceHolder(options, instance.footer.find(selector), infos, 2);
292+
replacePlaceHolder(options, header, infos, 1);
293+
replacePlaceHolder(options, footer, infos, 2);
277294
}
278295
}
279296

@@ -282,7 +299,16 @@
282299
if (options.navigation !== 0)
283300
{
284301
var instance = getInstance(element),
285-
tpl = options.templates,
302+
selector = getSelector(options.css.pagination),
303+
header = instance.header.find(selector)._bgShowAria(context.rowCount !== -1),
304+
footer = instance.footer.find(selector)._bgShowAria(context.rowCount !== -1);
305+
306+
if (context.rowCount === -1)
307+
{
308+
return;
309+
}
310+
311+
var tpl = options.templates,
286312
current = context.current,
287313
totalPages = context.totalPages,
288314
pagination = $(tpl.pagination.resolve(getParams(context))),
@@ -292,8 +318,7 @@
292318
Math.max(offsetLeft, 1) :
293319
Math.max((offsetLeft - options.padding + offsetRight), 1)),
294320
maxCount = options.padding * 2 + 1,
295-
count = (totalPages >= maxCount) ? maxCount : totalPages,
296-
selector = getSelector(options.css.pagination);
321+
count = (totalPages >= maxCount) ? maxCount : totalPages;
297322

298323
renderPaginationItem(element, options, context, pagination, "first", "«", "first")
299324
._bgEnableAria(current > 1);
@@ -307,13 +332,19 @@
307332
._bgEnableAria()._bgSelectAria(pos === current);
308333
}
309334

335+
if (count === 0)
336+
{
337+
renderPaginationItem(element, options, context, pagination, 1, 1, "page-" + 1)
338+
._bgEnableAria(false)._bgSelectAria();
339+
}
340+
310341
renderPaginationItem(element, options, context, pagination, "next", ">", "next")
311342
._bgEnableAria(totalPages > current);
312343
renderPaginationItem(element, options, context, pagination, "last", "»", "last")
313344
._bgEnableAria(totalPages > current);
314345

315-
replacePlaceHolder(options, instance.header.find(selector), pagination, 1);
316-
replacePlaceHolder(options, instance.footer.find(selector), pagination, 2);
346+
replacePlaceHolder(options, header, pagination, 1);
347+
replacePlaceHolder(options, footer, pagination, 2);
317348
}
318349
}
319350

build/jquery.bootgrid.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"current": 1,
3-
"rowCount": 5,
3+
"rowCount": 10,
44
"rows": [
55
{
66
"id": "a0e3a286-4343-4240-8d6d-e79fa2e94b4c",
@@ -28,5 +28,5 @@
2828
"received": "2014-04-15 11:23:06Z"
2929
}
3030
],
31-
"total": 510
31+
"total": 5
3232
}

0 commit comments

Comments
 (0)