Skip to content

Commit 859cb75

Browse files
committed
Improved multi selection
1 parent ee2dc65 commit 859cb75

File tree

10 files changed

+57
-14
lines changed

10 files changed

+57
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Enhancements & Features
66
- (Done) New option to switch the search behaviour from case sensitive to case insensitive.
7-
- Individual column filters
7+
- Individual basic column filters
88
- (Done) Custom CSS classes for header and body cells (solved issue [#7](http://github.com/rstaib/jquery-bootgrid/issues/7))
99
- (Done) New data attribute `data-toggle` to initialize bootgrid without writing any line of code (like bootstrap controls support)
1010
- (Done) Request and response handler to support JSON object transformation (solved issue [#3](http://github.com/rstaib/jquery-bootgrid/issues/3))
@@ -22,6 +22,9 @@
2222
- (Done) Fixed an AJAX issue where multiple fast clicks could lead to strange results
2323
- (Done) Fixed multi select issue
2424

25+
### Breaking Changes
26+
There are breaking changes but some HTML templates changed during development. In case you want to use the full new feature set be sure you did not override any affected templates.
27+
2528
## 1.0.0
2629

2730
### Enhancements & Features
143 Bytes
Binary file not shown.
258 Bytes
Binary file not shown.

build/jquery.bootgrid.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
.bootgrid-footer {
33
margin: 15px 0;
44
}
5+
.bootgrid-header a,
6+
.bootgrid-footer a {
7+
outline: 0;
8+
}
59
.bootgrid-header .search,
610
.bootgrid-footer .search {
711
display: inline-block;
@@ -61,6 +65,9 @@
6165
.bootgrid-table {
6266
table-layout: fixed;
6367
}
68+
.bootgrid-table a {
69+
outline: 0;
70+
}
6471
.bootgrid-table th > .column-header-anchor {
6572
color: #333;
6673
cursor: not-allowed;
@@ -86,6 +93,10 @@
8693
right: 0;
8794
top: 2px;
8895
}
96+
.bootgrid-table th:hover,
97+
.bootgrid-table th:active {
98+
background: #fafafa;
99+
}
89100
.bootgrid-table td {
90101
overflow: hidden;
91102
-ms-text-overflow: ellipsis;
@@ -106,6 +117,7 @@
106117
.bootgrid-table th.select-cell .select-box,
107118
.bootgrid-table td.select-cell .select-box {
108119
margin: 0;
120+
outline: 0;
109121
}
110122
.table-responsive .bootgrid-table {
111123
table-layout: inherit !important;

build/jquery.bootgrid.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
headerCssClass: data.headerCssClass || "",
116116
formatter: that.options.formatters[data.formatter] || null,
117117
order: (!sorted && (data.order === "asc" || data.order === "desc")) ? data.order : null,
118+
filterable: (data.filterable === true), // default: false
118119
searchable: !(data.searchable === false), // default: true
119120
sortable: !(data.sortable === false), // default: true
120121
visible: !(data.visible === false) // default: true
@@ -1084,6 +1085,14 @@
10841085
**/
10851086
responseHandler: function (response) { return response; },
10861087

1088+
/**
1089+
* A list of converters.
1090+
*
1091+
* @property converters
1092+
* @type Object
1093+
* @for defaults
1094+
* @since 1.0.0
1095+
**/
10871096
converters: {
10881097
numeric: {
10891098
from: function (value) { return +value; }, // converts from string to numeric
@@ -1411,13 +1420,15 @@
14111420

14121421
if (selectedRows.length > 0)
14131422
{
1414-
var selectBoxSelector = getCssSelector(this.options.css.selectBox);
1423+
var selectBoxSelector = getCssSelector(this.options.css.selectBox),
1424+
selectMultiSelectBox = this.selectedRows.length >= this.currentRows.length;
14151425

1416-
// todo: the "if" statement must be refactored for maintain selection feature
1417-
if (this.selectedRows.length === this.currentRows.length)
1426+
i = 0;
1427+
while (!this.options.keepSelection && selectMultiSelectBox && i < this.currentRows.length)
14181428
{
1419-
this.element.find("thead " + selectBoxSelector).prop("checked", true);
1429+
selectMultiSelectBox = ($.inArray(this.currentRows[i++][this.identifier], this.selectedRows) !== -1);
14201430
}
1431+
this.element.find("thead " + selectBoxSelector).prop("checked", selectMultiSelectBox);
14211432

14221433
if (!this.options.multiSelect)
14231434
{

build/jquery.bootgrid.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
<button id="removeSelected" type="button" class="btn btn-default">Remove Selected</button>
5353
<button id="destroy" type="button" class="btn btn-default">Destroy</button>
5454
<button id="init" type="button" class="btn btn-default">Init</button>
55-
<div class="table-responsive">
55+
<!--div class="table-responsive"-->
5656
<table id="grid" class="table table-condensed table-hover table-striped" data-selection="true" data-multi-select="true" data-row-select="true" data-keep-selection="true">
5757
<thead>
5858
<tr>
5959
<th data-column-id="id" data-identifier="true" data-type="numeric" data-align="right">ID</th>
6060
<th data-column-id="sender" data-order="asc" data-align="center" data-header-align="center">Sender</th>
61-
<th data-column-id="received" data-css-class="cell" data-header-css-class="column">Received</th>
61+
<th data-column-id="received" data-css-class="cell" data-header-css-class="column" data-filterable="true">Received</th>
6262
<th data-column-id="link" data-formatter="link" data-sortable="false">Link</th>
6363
</tr>
6464
</thead>
@@ -131,7 +131,7 @@
131131
</tr>
132132
</tbody>
133133
</table>
134-
</div>
134+
<!--/div-->
135135
</div>
136136
</div>
137137
</div>

src/internal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function loadColumns()
105105
headerCssClass: data.headerCssClass || "",
106106
formatter: that.options.formatters[data.formatter] || null,
107107
order: (!sorted && (data.order === "asc" || data.order === "desc")) ? data.order : null,
108+
filterable: (data.filterable === true), // default: false
108109
searchable: !(data.searchable === false), // default: true
109110
sortable: !(data.sortable === false), // default: true
110111
visible: !(data.visible === false) // default: true

src/jquery.bootgrid.less

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
{
2828
margin: 15px 0;
2929

30+
a { outline: 0; }
31+
3032
.search
3133
{
3234
display: inline-block;
@@ -91,6 +93,8 @@
9193
{
9294
table-layout: fixed;
9395

96+
a { outline: 0; }
97+
9498
th
9599
{
96100
& > .column-header-anchor
@@ -118,6 +122,8 @@
118122
top: 2px;
119123
}
120124
}
125+
126+
&:hover, &:active { background: #fafafa; }
121127
}
122128

123129
td
@@ -136,7 +142,7 @@
136142
text-align: center;
137143
width: 30px;
138144

139-
.select-box { margin: 0; }
145+
.select-box { margin: 0; outline: 0; }
140146
}
141147
}
142148

src/public.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ Grid.defaults = {
169169
**/
170170
responseHandler: function (response) { return response; },
171171

172+
/**
173+
* A list of converters.
174+
*
175+
* @property converters
176+
* @type Object
177+
* @for defaults
178+
* @since 1.0.0
179+
**/
172180
converters: {
173181
numeric: {
174182
from: function (value) { return +value; }, // converts from string to numeric
@@ -496,13 +504,15 @@ Grid.prototype.select = function(rowIds)
496504

497505
if (selectedRows.length > 0)
498506
{
499-
var selectBoxSelector = getCssSelector(this.options.css.selectBox);
507+
var selectBoxSelector = getCssSelector(this.options.css.selectBox),
508+
selectMultiSelectBox = this.selectedRows.length >= this.currentRows.length;
500509

501-
// todo: the "if" statement must be refactored for maintain selection feature
502-
if (this.selectedRows.length === this.currentRows.length)
510+
i = 0;
511+
while (!this.options.keepSelection && selectMultiSelectBox && i < this.currentRows.length)
503512
{
504-
this.element.find("thead " + selectBoxSelector).prop("checked", true);
513+
selectMultiSelectBox = ($.inArray(this.currentRows[i++][this.identifier], this.selectedRows) !== -1);
505514
}
515+
this.element.find("thead " + selectBoxSelector).prop("checked", selectMultiSelectBox);
506516

507517
if (!this.options.multiSelect)
508518
{

0 commit comments

Comments
 (0)