From e194f8f0a68a60ced3234bbd5dd52f8d8b5a9180 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Wed, 31 Aug 2016 12:44:10 -0700
Subject: [PATCH 01/23] Added includeHidden search option
---
CHANGELOG.md | 3 ++
demo/ajax.htm | 107 +++++++++++++++++++++++++++++++++++++
demo/data.json | 61 +++++++++++----------
demo/index.htm | 5 +-
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 16 ++++--
npm-debug.log | 44 +++++++++++++++
src/internal.js | 2 +-
src/public.js | 12 ++++-
10 files changed, 215 insertions(+), 39 deletions(-)
create mode 100644 demo/ajax.htm
create mode 100644 npm-debug.log
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e5ac42b..2254ea2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@
### Bug Fixes
- Fixed bug with showing/hiding columns
+### Enhancements & Features
+- Added options for search to include hidden columns
+
## 1.4.1
### Bug Fixes
diff --git a/demo/ajax.htm b/demo/ajax.htm
new file mode 100644
index 0000000..c2ce5b0
--- /dev/null
+++ b/demo/ajax.htm
@@ -0,0 +1,107 @@
+
+
+
+
+
+ jQuery Bootgrid Demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | ID |
+ Sender |
+ Received |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/data.json b/demo/data.json
index b177807..5c20b79 100644
--- a/demo/data.json
+++ b/demo/data.json
@@ -1,32 +1,31 @@
{
- "current": 1,
- "rowCount": 5,
- "rows": [
- {
- "id": "a0e3a286-4343-4240-8d6d-e79fa2e94b4c",
- "sender": "test@test.de",
- "received": "2014-04-17 15:08:03Z"
- },
- {
- "id": "dd9f2d42-9442-404c-8d2a-dd3bd2156c03",
- "sender": "test@test.de",
- "received": "2014-04-16 15:19:31Z"
- },
- {
- "id": "e9b8ede5-c1bf-4d90-b724-e7379b25f7b3",
- "sender": "test@test.de",
- "received": "2014-04-16 15:17:05Z"
- },
- {
- "id": "153d3acb-efe7-4b5f-a3a9-e8ac18bdec30",
- "sender": "test@test.de",
- "received": "2014-04-16 15:17:05Z"
- },
- {
- "id": "49bad60a-bbf7-42bf-b040-d901805ccbf1",
- "sender": "test@test.de",
- "received": "2014-04-15 11:23:06Z"
- }
- ],
- "total": 5
-}
\ No newline at end of file
+ "current": 1,
+ "rowCount": 5,
+ "rows": [{
+ "id": "a0e3a286-4343-4240-8d6d-e79fa2e94b4c",
+ "sender": "test@test.de",
+ "received": "2014-04-17 15:08:03Z",
+ "checked": true
+ }, {
+ "id": "dd9f2d42-9442-404c-8d2a-dd3bd2156c03",
+ "sender": "test@test.de",
+ "received": "2014-04-16 15:19:31Z",
+ "checked": true
+ }, {
+ "id": "e9b8ede5-c1bf-4d90-b724-e7379b25f7b3",
+ "sender": "test@test.de",
+ "received": "2014-04-16 15:17:05Z",
+ "checked": false
+ }, {
+ "id": "153d3acb-efe7-4b5f-a3a9-e8ac18bdec30",
+ "sender": "test@test.de",
+ "received": "2014-04-16 15:17:05Z",
+ "checked": true
+ }, {
+ "id": "49bad60a-bbf7-42bf-b040-d901805ccbf1",
+ "sender": "test@test.de",
+ "received": "2014-04-15 11:23:06Z",
+ "checked": false
+ }],
+ "total": 5
+}
diff --git a/demo/index.htm b/demo/index.htm
index be96906..266fe24 100644
--- a/demo/index.htm
+++ b/demo/index.htm
@@ -479,7 +479,10 @@
}
},
caseSensitive: false,
- rowCount: [-1, 5, 10, 15]
+ rowCount: [-1, 5, 10, 15],
+ searchSettings:{
+ includeHidden: false
+ }
});
}
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 3beaa72..79efdcc 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/10/2016
+ * jQuery Bootgrid v1.4.1 - 08/31/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 418ba75..70c0a7a 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/10/2016
+ * jQuery Bootgrid v1.4.1 - 08/31/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 0961795..760f385 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/10/2016
+ * jQuery Bootgrid v1.4.1 - 08/31/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -159,7 +159,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
- if (column.searchable && column.visible &&
+ if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
column.converter.to(row[column.id]).search(searchPattern) > -1) {
return true;
}
@@ -1035,7 +1035,17 @@ Grid.defaults = {
* @default 1
* @for searchSettings
**/
- characters: 1
+ characters: 1,
+
+ /**
+ * Option if search should ignore hidden columns
+ *
+ * @property includeHidden
+ * @type Boolean
+ * @default false
+ * @for searchSettings
+ **/
+ includeHidden: false
},
/**
diff --git a/npm-debug.log b/npm-debug.log
new file mode 100644
index 0000000..7d6413a
--- /dev/null
+++ b/npm-debug.log
@@ -0,0 +1,44 @@
+0 info it worked if it ends with ok
+1 verbose cli [ '/usr/local/bin/node',
+1 verbose cli '/usr/local/bin/npm',
+1 verbose cli 'version',
+1 verbose cli 'minor' ]
+2 info using npm@3.10.3
+3 info using node@v6.4.0
+4 info git [ 'status', '--porcelain' ]
+5 verbose stack Error: Git working directory not clean.
+5 verbose stack M CHANGELOG.md
+5 verbose stack M demo/data.json
+5 verbose stack M demo/index.htm
+5 verbose stack M dist/jquery.bootgrid.css
+5 verbose stack M dist/jquery.bootgrid.fa.js
+5 verbose stack M dist/jquery.bootgrid.js
+5 verbose stack M src/internal.js
+5 verbose stack M src/public.js
+5 verbose stack at /usr/local/lib/node_modules/npm/lib/version.js:247:19
+5 verbose stack at /usr/local/lib/node_modules/npm/lib/utils/no-progress-while-running.js:21:8
+5 verbose stack at ChildProcess.exithandler (child_process.js:197:7)
+5 verbose stack at emitTwo (events.js:106:13)
+5 verbose stack at ChildProcess.emit (events.js:191:7)
+5 verbose stack at maybeClose (internal/child_process.js:852:16)
+5 verbose stack at Socket. (internal/child_process.js:323:11)
+5 verbose stack at emitOne (events.js:96:13)
+5 verbose stack at Socket.emit (events.js:188:7)
+5 verbose stack at Pipe._handle.close [as _onclose] (net.js:492:12)
+6 verbose cwd /Users/mgroth/Documents/GitHub/jquery-bootgrid
+7 error Darwin 16.0.0
+8 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "version" "minor"
+9 error node v6.4.0
+10 error npm v3.10.3
+11 error Git working directory not clean.
+11 error M CHANGELOG.md
+11 error M demo/data.json
+11 error M demo/index.htm
+11 error M dist/jquery.bootgrid.css
+11 error M dist/jquery.bootgrid.fa.js
+11 error M dist/jquery.bootgrid.js
+11 error M src/internal.js
+11 error M src/public.js
+12 error If you need help, you may report this error at:
+12 error
+13 verbose exit [ 1, true ]
diff --git a/src/internal.js b/src/internal.js
index 870b473..4e7fbb5 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -149,7 +149,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
- if (column.searchable && column.visible &&
+ if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
column.converter.to(row[column.id]).search(searchPattern) > -1) {
return true;
}
diff --git a/src/public.js b/src/public.js
index a691dec..83a1bc0 100644
--- a/src/public.js
+++ b/src/public.js
@@ -148,7 +148,17 @@ Grid.defaults = {
* @default 1
* @for searchSettings
**/
- characters: 1
+ characters: 1,
+
+ /**
+ * Option if search should ignore hidden columns
+ *
+ * @property includeHidden
+ * @type Boolean
+ * @default false
+ * @for searchSettings
+ **/
+ includeHidden: false
},
/**
From 8c62420717dc90faa7c759318ca031461a1bce8e Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Wed, 31 Aug 2016 12:45:29 -0700
Subject: [PATCH 02/23] 1.4.2
---
package.json | 136 ++++++++++++++++++++++++++-------------------------
1 file changed, 70 insertions(+), 66 deletions(-)
diff --git a/package.json b/package.json
index e871f4c..5437f95 100644
--- a/package.json
+++ b/package.json
@@ -1,68 +1,72 @@
{
- "name": "jquery-bootgrid",
- "namespace": "jquery.bootgrid",
- "title": "jQuery Bootgrid",
- "version": "1.4.1",
- "description": "Nice, sleek and intuitive. A grid control especially designed for bootstrap.",
- "homepage": "http://www.jquery-bootgrid.com",
- "author": {
- "name": "Rafael Staib",
- "email": "me@rafaelstaib.com",
- "url": "http://www.rafaelstaib.com"
- },
- "contributors": [{
- "name": "Matt Groth",
- "email": "mattgroth85@gmail.com",
- "url": "https://github.com/Iodine-"
- }],
- "bugs": "https://github.com/MoveInc/jquery-bootgrid/issues",
- "scripts": {
- "test": "grunt"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/MoveInc/jquery-bootgrid.git"
- },
- "keywords": [
- "jquery-plugin",
- "jQuery",
- "Bootstrap",
- "Plugin",
- "Component",
- "Control",
- "UI",
- "Grid",
- "Table",
- "Data",
- "Sorting",
- "Filtering",
- "HTML5",
- "Accessibility"
- ],
- "licenses": [{
- "type": "MIT",
- "url": "http://www.opensource.org/licenses/MIT"
- }],
- "dependencies": {
- "jquery": ">=1.9.0",
- "bootstrap": ">=3.1.1"
- },
- "devDependencies": {
- "grunt": "^1.0.1",
- "grunt-cli": "^1.2.0",
- "grunt-contrib-clean": "^1.0.0",
- "grunt-contrib-compress": "^1.3.0",
- "grunt-contrib-concat": "^1.0.1",
- "grunt-contrib-csslint": "^1.0.0",
- "grunt-contrib-cssmin": "^1.0.1",
- "grunt-contrib-jshint": "^1.0.0",
- "grunt-contrib-less": "^1.3.0",
- "grunt-contrib-qunit": "^1.2.0",
- "grunt-contrib-uglify": "^2.0.0",
- "grunt-contrib-yuidoc": "^1.0.0",
- "grunt-exec": "^1.0.0",
- "grunt-nuget": "~0.1.4",
- "grunt-regex-replace": "^0.3.0"
- },
- "readmeFilename": "README.md"
+ "name": "jquery-bootgrid",
+ "namespace": "jquery.bootgrid",
+ "title": "jQuery Bootgrid",
+ "version": "1.4.2",
+ "description": "Nice, sleek and intuitive. A grid control especially designed for bootstrap.",
+ "homepage": "http://www.jquery-bootgrid.com",
+ "author": {
+ "name": "Rafael Staib",
+ "email": "me@rafaelstaib.com",
+ "url": "http://www.rafaelstaib.com"
+ },
+ "contributors": [
+ {
+ "name": "Matt Groth",
+ "email": "mattgroth85@gmail.com",
+ "url": "https://github.com/Iodine-"
+ }
+ ],
+ "bugs": "https://github.com/MoveInc/jquery-bootgrid/issues",
+ "scripts": {
+ "test": "grunt"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/MoveInc/jquery-bootgrid.git"
+ },
+ "keywords": [
+ "jquery-plugin",
+ "jQuery",
+ "Bootstrap",
+ "Plugin",
+ "Component",
+ "Control",
+ "UI",
+ "Grid",
+ "Table",
+ "Data",
+ "Sorting",
+ "Filtering",
+ "HTML5",
+ "Accessibility"
+ ],
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://www.opensource.org/licenses/MIT"
+ }
+ ],
+ "dependencies": {
+ "jquery": ">=1.9.0",
+ "bootstrap": ">=3.1.1"
+ },
+ "devDependencies": {
+ "grunt": "^1.0.1",
+ "grunt-cli": "^1.2.0",
+ "grunt-contrib-clean": "^1.0.0",
+ "grunt-contrib-compress": "^1.3.0",
+ "grunt-contrib-concat": "^1.0.1",
+ "grunt-contrib-csslint": "^1.0.0",
+ "grunt-contrib-cssmin": "^1.0.1",
+ "grunt-contrib-jshint": "^1.0.0",
+ "grunt-contrib-less": "^1.3.0",
+ "grunt-contrib-qunit": "^1.2.0",
+ "grunt-contrib-uglify": "^2.0.0",
+ "grunt-contrib-yuidoc": "^1.0.0",
+ "grunt-exec": "^1.0.0",
+ "grunt-nuget": "~0.1.4",
+ "grunt-regex-replace": "^0.3.0"
+ },
+ "readmeFilename": "README.md"
}
From cf5241c4982e182ff954747a3a45a2cbe38e9bf4 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Thu, 1 Sep 2016 12:15:50 -0700
Subject: [PATCH 03/23] updated sort function to use column converter
---
CHANGELOG.md | 5 +++++
bower.json | 2 +-
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 9 ++++++++-
src/internal.js | 7 +++++++
6 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2254ea2..b2953cb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 1.4.3
+
+### Enhancements & Features
+- Updated sort function to use column converter if it exists
+
## 1.4.2
### Bug Fixes
diff --git a/bower.json b/bower.json
index 600d5f1..45fbf86 100644
--- a/bower.json
+++ b/bower.json
@@ -13,7 +13,7 @@
"accessibility",
"bootstrap"
],
- "version": "1.4.1",
+ "version": "1.4.2",
"authors": [
{
"name": "Rafael Staib",
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 79efdcc..a170671 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 70c0a7a..7d29397 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 760f385..d99b7c6 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -862,6 +862,13 @@ function sortRows() {
var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ // if column has a converter, use it
+ var col = that.getColumnSettings({id: item.id});
+ if(col.length > 0){
+ a = col[0].converter ? col[0].converter.to(a, x) : a;
+ b = col[0].converter ? col[0].converter.to(b, y) : b;
+ }
+
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
(sortArray.length > next) ? sort(x, y, next) : 0;
diff --git a/src/internal.js b/src/internal.js
index 4e7fbb5..7363865 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -852,6 +852,13 @@ function sortRows() {
var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ // if column has a converter, use it
+ var col = that.getColumnSettings({id: item.id});
+ if(col.length > 0){
+ a = col[0].converter ? col[0].converter.to(a, x) : a;
+ b = col[0].converter ? col[0].converter.to(b, y) : b;
+ }
+
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
(sortArray.length > next) ? sort(x, y, next) : 0;
From 821343a6a788ec4137f765e07b343a46bae56c15 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Thu, 1 Sep 2016 12:26:18 -0700
Subject: [PATCH 04/23] added row param for search converter call
---
CHANGELOG.md | 1 +
src/internal.js | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2953cb..16d13ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### Enhancements & Features
- Updated sort function to use column converter if it exists
+- Updated search to pass row to converter
## 1.4.2
diff --git a/src/internal.js b/src/internal.js
index 7363865..2ac767b 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -150,7 +150,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id]).search(searchPattern) > -1) {
+ column.converter.to(row[column.id], row).search(searchPattern) > -1) {
return true;
}
}
@@ -579,7 +579,7 @@ function renderRows(rows) {
if (column.visible) {
var value = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, row) :
- column.converter.to(row[column.id]),
+ column.converter.to(row[column.id], row),
cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
cells += tpl.cell.resolve(getParams.call(that, {
content: (value == null || value === "") ? " " : value,
From bbebd19fd27d25e4c2c032ac58bb80ee22fad4b5 Mon Sep 17 00:00:00 2001
From: Dreae
Date: Thu, 1 Sep 2016 17:07:53 -0400
Subject: [PATCH 05/23] Add ability to provide data through a function call
---
bower.json | 2 +-
demo/dataFunc.htm | 137 +++++++++++++++++++++++++++++++++++++
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 22 ++++--
npm-debug.log | 44 ------------
src/internal.js | 20 +++++-
7 files changed, 175 insertions(+), 54 deletions(-)
create mode 100644 demo/dataFunc.htm
delete mode 100644 npm-debug.log
diff --git a/bower.json b/bower.json
index 600d5f1..45fbf86 100644
--- a/bower.json
+++ b/bower.json
@@ -13,7 +13,7 @@
"accessibility",
"bootstrap"
],
- "version": "1.4.1",
+ "version": "1.4.2",
"authors": [
{
"name": "Rafael Staib",
diff --git a/demo/dataFunc.htm b/demo/dataFunc.htm
new file mode 100644
index 0000000..4731695
--- /dev/null
+++ b/demo/dataFunc.htm
@@ -0,0 +1,137 @@
+
+
+
+
+
+ jQuery Bootgrid Demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | ID |
+ Sender |
+ Received |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 79efdcc..a170671 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 70c0a7a..7d29397 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 760f385..9bf5108 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.1 - 08/31/2016
+ * jQuery Bootgrid v1.4.2 - 09/01/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -223,6 +223,20 @@ function loadData() {
settings = $.extend(this.options.ajaxSettings, settings);
this.xqr = $.ajax(settings);
+ } else if (this.options.dataFunc) {
+ var querySettings = {
+ data: getRequest.call(this),
+ success: function(response) {
+ that.current = response.current;
+ update(response.rows, response.total);
+ },
+ error: function(err) {
+ renderNoResultsRow.call(that); // overrides loading mask
+ that.element._bgBusyAria(false).trigger("loaded" + namespace);
+ }
+ };
+
+ this.options.dataFunc(querySettings);
} else {
var rows = (this.searchPhrase.length > 0) ? this.rows.where(containsPhrase) : this.rows,
total = rows.length;
@@ -239,7 +253,7 @@ function loadData() {
}
function loadRows() {
- if (!this.options.ajax) {
+ if (!this.options.ajax && !this.options.dataFunc) {
var that = this,
rows = this.element.find("tbody > tr");
@@ -305,7 +319,7 @@ function renderActions() {
actions = $(tpl.actions.resolve(getParams.call(this)));
// Refresh Button
- if (this.options.ajax) {
+ if (this.options.ajax || this.options.dataFunc) {
var refreshIcon = tpl.icon.resolve(getParams.call(this, {
iconCss: css.iconRefresh
})),
@@ -867,7 +881,7 @@ function sortRows() {
(sortArray.length > next) ? sort(x, y, next) : 0;
}
- if (!this.options.ajax) {
+ if (!this.options.ajax || !this.options.dataFunc) {
var that = this;
for (var key in this.sortDictionary) {
diff --git a/npm-debug.log b/npm-debug.log
deleted file mode 100644
index 7d6413a..0000000
--- a/npm-debug.log
+++ /dev/null
@@ -1,44 +0,0 @@
-0 info it worked if it ends with ok
-1 verbose cli [ '/usr/local/bin/node',
-1 verbose cli '/usr/local/bin/npm',
-1 verbose cli 'version',
-1 verbose cli 'minor' ]
-2 info using npm@3.10.3
-3 info using node@v6.4.0
-4 info git [ 'status', '--porcelain' ]
-5 verbose stack Error: Git working directory not clean.
-5 verbose stack M CHANGELOG.md
-5 verbose stack M demo/data.json
-5 verbose stack M demo/index.htm
-5 verbose stack M dist/jquery.bootgrid.css
-5 verbose stack M dist/jquery.bootgrid.fa.js
-5 verbose stack M dist/jquery.bootgrid.js
-5 verbose stack M src/internal.js
-5 verbose stack M src/public.js
-5 verbose stack at /usr/local/lib/node_modules/npm/lib/version.js:247:19
-5 verbose stack at /usr/local/lib/node_modules/npm/lib/utils/no-progress-while-running.js:21:8
-5 verbose stack at ChildProcess.exithandler (child_process.js:197:7)
-5 verbose stack at emitTwo (events.js:106:13)
-5 verbose stack at ChildProcess.emit (events.js:191:7)
-5 verbose stack at maybeClose (internal/child_process.js:852:16)
-5 verbose stack at Socket. (internal/child_process.js:323:11)
-5 verbose stack at emitOne (events.js:96:13)
-5 verbose stack at Socket.emit (events.js:188:7)
-5 verbose stack at Pipe._handle.close [as _onclose] (net.js:492:12)
-6 verbose cwd /Users/mgroth/Documents/GitHub/jquery-bootgrid
-7 error Darwin 16.0.0
-8 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "version" "minor"
-9 error node v6.4.0
-10 error npm v3.10.3
-11 error Git working directory not clean.
-11 error M CHANGELOG.md
-11 error M demo/data.json
-11 error M demo/index.htm
-11 error M dist/jquery.bootgrid.css
-11 error M dist/jquery.bootgrid.fa.js
-11 error M dist/jquery.bootgrid.js
-11 error M src/internal.js
-11 error M src/public.js
-12 error If you need help, you may report this error at:
-12 error
-13 verbose exit [ 1, true ]
diff --git a/src/internal.js b/src/internal.js
index 4e7fbb5..ffd0f24 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -213,6 +213,20 @@ function loadData() {
settings = $.extend(this.options.ajaxSettings, settings);
this.xqr = $.ajax(settings);
+ } else if (this.options.dataFunc) {
+ var querySettings = {
+ data: getRequest.call(this),
+ success: function(response) {
+ that.current = response.current;
+ update(response.rows, response.total);
+ },
+ error: function(err) {
+ renderNoResultsRow.call(that); // overrides loading mask
+ that.element._bgBusyAria(false).trigger("loaded" + namespace);
+ }
+ };
+
+ this.options.dataFunc(querySettings);
} else {
var rows = (this.searchPhrase.length > 0) ? this.rows.where(containsPhrase) : this.rows,
total = rows.length;
@@ -229,7 +243,7 @@ function loadData() {
}
function loadRows() {
- if (!this.options.ajax) {
+ if (!this.options.ajax && !this.options.dataFunc) {
var that = this,
rows = this.element.find("tbody > tr");
@@ -295,7 +309,7 @@ function renderActions() {
actions = $(tpl.actions.resolve(getParams.call(this)));
// Refresh Button
- if (this.options.ajax) {
+ if (this.options.ajax || this.options.dataFunc) {
var refreshIcon = tpl.icon.resolve(getParams.call(this, {
iconCss: css.iconRefresh
})),
@@ -857,7 +871,7 @@ function sortRows() {
(sortArray.length > next) ? sort(x, y, next) : 0;
}
- if (!this.options.ajax) {
+ if (!this.options.ajax || !this.options.dataFunc) {
var that = this;
for (var key in this.sortDictionary) {
From fe87724d587d08ff5e03e4e094be88b48c438877 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Tue, 20 Sep 2016 15:44:24 -0700
Subject: [PATCH 06/23] Add derived columns
---
CHANGELOG.md | 8 +-
demo/derived.htm | 297 +++++++++++++++++++++++++++++++++++++
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 109 ++++++++++++--
src/internal.js | 65 +++++---
src/public.js | 49 +++++-
7 files changed, 492 insertions(+), 40 deletions(-)
create mode 100644 demo/derived.htm
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 16d13ac..acf6b3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,12 @@
## 1.4.3
### Enhancements & Features
-- Updated sort function to use column converter if it exists
-- Updated search to pass row to converter
+- Updated search to pass row, column, and grid to converter
+- Add derived cell support with a derived formatter
+ - Adds additional `sortKey` parameter to determine which reference should be considered for sorting
+- Add `sortRendered` parameter that uses the rendered cell value as the comparator
+ - Useful is situations where the formatter expects values other than what you want to sort on
+- Add `derived` formatter and converter to defaults
## 1.4.2
diff --git a/demo/derived.htm b/demo/derived.htm
new file mode 100644
index 0000000..28813e6
--- /dev/null
+++ b/demo/derived.htm
@@ -0,0 +1,297 @@
+
+
+
+
+
+ jQuery Bootgrid Demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | ID |
+ Name |
+ Sender |
+ Received |
+ Company |
+ Cost |
+
+ Derived
+ |
+ Hidden |
+
+
+
+
+ | 1 |
+ {"text": "Aimee Delaney", "url":"http://www.aaa.ca"} |
+ erat.vitae@estvitaesodales.com |
+ 03.06.16 |
+ Maecenas Malesuada Foundation |
+ 222222 |
+
+
+ |
+ C9F35176-EE9C-7DA5-DB47-5B62C57AA176 |
+
+
+ | 2 |
+ {"text": "BORIS BULE", "url": "http://www.zzz.ca"} |
+ vitae.diam@Proinultrices.edu |
+ 10.12.16 |
+ Ac Corporation |
+ 11111111 |
+
+
+ |
+ 1BC83AA2-0979-C426-A3B4-4CC4F8B0CFF9 |
+
+
+ | 3 |
+ {"text": "ALEX Reese", "url": "http://www.ccc.com"} |
+ mauris.sit.amet@nonmassa.ca |
+ 27.06.17 |
+ Nulla At Incorporated |
+ 333333333 |
+
+
+ |
+ C3CF97AE-0E0E-EA4E-FBF5-A63444134B8E |
+
+
+ | 4 |
+ {"text": "Juliet Mcfarland", "url": "http://www.eee.com"} |
+ egestas.Duis.ac@eu.net |
+ 02.07.16 |
+ Nisi Sem Semper Limited |
+ 555555 |
+
+
+ |
+ 33AC322B-8AB4-B9F0-FAF0-BD69A7937627 |
+
+
+ | 5 |
+ {"url": "http://www.ddd.com", "text": "Aaron Weaver"} |
+ Curabitur@fermentumconvallisligula.org |
+ 07.06.17 |
+ Magna Nec Quam Industries |
+ 4444444 |
+
+
+ |
+ 235B6F73-2150-A423-DC0A-A75C74669824 |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index a170671..c6f618f 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 7d29397..423d5c1 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 948d604..113e584 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -113,6 +113,9 @@ function loadColumns() {
order: (!sorted && (data.order === "asc" || data.order === "desc")) ? data.order : null,
searchable: !(data.searchable === false), // default: true
sortable: !(data.sortable === false), // default: true
+ sortKey: data.sortKey || '',
+ sortRendered: data.sortRendered || false, // default: false
+ rows: data.derivedRows || [],
visible: !(data.visible === false), // default: true
visibleInSelection: !(data.visibleInSelection === false), // default: true
width: ($.isNumeric(data.width)) ? data.width + "px" :
@@ -159,8 +162,8 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
- if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id]).search(searchPattern) > -1) {
+ if (column.searchable && (column.visible || that.options.searchSettings.includeHidden) &&
+ column.converter.to(row[column.id], row, column, that).search(searchPattern) > -1) {
return true;
}
}
@@ -385,7 +388,7 @@ function renderColumnSelection(actions) {
loadData.call(that);
}
})
- .on("change" + namespace, checkboxSelector, function(e){
+ .on("change" + namespace, checkboxSelector, function(e) {
var $this = $(this);
that.element.trigger('toggleColumn', [column.id, column.text, column.visible]);
});
@@ -537,12 +540,12 @@ function renderRowCountSelection(actions) {
var $this = $(this),
newRowCount = $this.data("action");
if (newRowCount !== that.rowCount) {
- if(that.options.resolvePageFromRowCount){
+ if (that.options.resolvePageFromRowCount) {
var page = that.current > 1 ? that.current : 1;
- var skip = that.current > 1 ? that.rowCount * (that.current-1) + 1 : 0;
- var newPage = skip > 1 ? Math.ceil(skip/newRowCount) : 1;
+ var skip = that.current > 1 ? that.rowCount * (that.current - 1) + 1 : 0;
+ var newPage = skip > 1 ? Math.ceil(skip / newRowCount) : 1;
that.current = newRowCount > 0 ? newPage : 1;
- }else{
+ } else {
that.current = 1;
}
that.rowCount = newRowCount;
@@ -862,19 +865,52 @@ function showLoading() {
}
function sortRows() {
+ var that = this;
var sortArray = [];
function sort(x, y, current) {
current = current || 0;
var next = current + 1,
- item = sortArray[current];
+ item = sortArray[current],
+ cell = item.id;
function sortOrder(value) {
return (item.order === "asc") ? value : value * -1;
}
- var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
- var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ var column = that.getColumnSettings({
+ id: cell
+ })[0];
+
+ if (column.sortKey) {
+ cell = column.sortKey;
+ column = that.getColumnSettings({
+ id: cell
+ })[0];
+ }
+
+ var a = x[cell];
+ var b = y[cell];
+
+ if (column.sortRendered) {
+ a = ($.isFunction(column.formatter)) ?
+ column.formatter.call(that, column, x) :
+ column.converter.to(x[column.id]);
+ try {
+ a = $(a).text();
+ } catch (e) {}
+ b = ($.isFunction(column.formatter)) ?
+ column.formatter.call(that, column, y) :
+ column.converter.to(y[column.id]);
+ try {
+ b = $(b).text();
+ } catch (e) {}
+ }
+
+ if (that.options.caseSensitive) {
+ a = $.type(a) === 'string' ? a.toLowerCase() : a;
+ b = $.type(b) === 'string' ? b.toLowerCase() : b;
+ }
// if column has a converter, use it
var col = that.getColumnSettings({id: item.id});
@@ -889,8 +925,6 @@ function sortRows() {
}
if (!this.options.ajax || !this.options.dataFunc) {
- var that = this;
-
for (var key in this.sortDictionary) {
if (this.options.multiSort || sortArray.length === 0) {
sortArray.push({
@@ -1178,7 +1212,28 @@ Grid.defaults = {
// default converter
from: function (value) { return value; },
to: function (value) { return value; }
- }
+ },
+ derived: {
+ // applies reference column converter to each row
+ to: function(val, row, column, grid) {
+ try {
+ var rows = column.rows.split(',');
+ var self = grid;
+ var compiledRows = [];
+ $.each(rows, function(index, element) {
+ var column = self.getColumnSettings({id: element})[0];
+ var content = column.converter.to(row[column.id]);
+ compiledRows.push(content);
+ });
+ return compiledRows.join('');
+ } catch (e) {
+ return val;
+ }
+ },
+ from: function(val) {
+ return val;
+ }
+ }
},
/**
@@ -1252,7 +1307,31 @@ Grid.defaults = {
* @for defaults
* @since 1.0.0
**/
- formatters: {},
+ formatters: {
+ 'derived': function(column, row) {
+ try {
+ var rows = column.rows.split(',');
+ var self = this;
+ var compiledRows = [];
+ $.each(rows, function(index, element) {
+ var content = row[element];
+ var template = element.template || '__data__
';
+ var column = self.getColumnSettings({id: element})[0];
+ if (element.formatter || column.formatter) {
+ var formatter = column.formatter || element.formatter;
+ content = ($.isFunction(formatter)) ?
+ formatter.call(self, column, row) :
+ column.converter.to(row[column.id]);
+ }
+ var data = template.replace('__data__', content);
+ compiledRows.push(data);
+ });
+ return compiledRows.join('');
+ } catch (e) {
+ return row[column.id];
+ }
+ }
+ },
/**
* Contains all labels.
diff --git a/src/internal.js b/src/internal.js
index 83d1b93..b08bedc 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -103,6 +103,9 @@ function loadColumns() {
order: (!sorted && (data.order === "asc" || data.order === "desc")) ? data.order : null,
searchable: !(data.searchable === false), // default: true
sortable: !(data.sortable === false), // default: true
+ sortKey: data.sortKey || '',
+ sortRendered: data.sortRendered || false, // default: false
+ rows: data.derivedRows || [],
visible: !(data.visible === false), // default: true
visibleInSelection: !(data.visibleInSelection === false), // default: true
width: ($.isNumeric(data.width)) ? data.width + "px" :
@@ -149,8 +152,8 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
- if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id], row).search(searchPattern) > -1) {
+ if (column.searchable && (column.visible || that.options.searchSettings.includeHidden) &&
+ column.converter.to(row[column.id], row, column, that).search(searchPattern) > -1) {
return true;
}
}
@@ -375,7 +378,7 @@ function renderColumnSelection(actions) {
loadData.call(that);
}
})
- .on("change" + namespace, checkboxSelector, function(e){
+ .on("change" + namespace, checkboxSelector, function(e) {
var $this = $(this);
that.element.trigger('toggleColumn', [column.id, column.text, column.visible]);
});
@@ -527,12 +530,12 @@ function renderRowCountSelection(actions) {
var $this = $(this),
newRowCount = $this.data("action");
if (newRowCount !== that.rowCount) {
- if(that.options.resolvePageFromRowCount){
+ if (that.options.resolvePageFromRowCount) {
var page = that.current > 1 ? that.current : 1;
- var skip = that.current > 1 ? that.rowCount * (that.current-1) + 1 : 0;
- var newPage = skip > 1 ? Math.ceil(skip/newRowCount) : 1;
+ var skip = that.current > 1 ? that.rowCount * (that.current - 1) + 1 : 0;
+ var newPage = skip > 1 ? Math.ceil(skip / newRowCount) : 1;
that.current = newRowCount > 0 ? newPage : 1;
- }else{
+ } else {
that.current = 1;
}
that.rowCount = newRowCount;
@@ -593,7 +596,7 @@ function renderRows(rows) {
if (column.visible) {
var value = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, row) :
- column.converter.to(row[column.id], row),
+ column.converter.to(row[column.id], row, column, that),
cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
cells += tpl.cell.resolve(getParams.call(that, {
content: (value == null || value === "") ? " " : value,
@@ -852,26 +855,52 @@ function showLoading() {
}
function sortRows() {
+ var that = this;
var sortArray = [];
function sort(x, y, current) {
current = current || 0;
var next = current + 1,
- item = sortArray[current];
+ item = sortArray[current],
+ cell = item.id;
function sortOrder(value) {
return (item.order === "asc") ? value : value * -1;
}
- var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
- var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ var column = that.getColumnSettings({
+ id: cell
+ })[0];
+
+ if (column.sortKey) {
+ cell = column.sortKey;
+ column = that.getColumnSettings({
+ id: cell
+ })[0];
+ }
- // if column has a converter, use it
- var col = that.getColumnSettings({id: item.id});
- if(col.length > 0){
- a = col[0].converter ? col[0].converter.to(a, x) : a;
- b = col[0].converter ? col[0].converter.to(b, y) : b;
- }
+ var a = x[cell];
+ var b = y[cell];
+
+ if (column.sortRendered) {
+ a = ($.isFunction(column.formatter)) ?
+ column.formatter.call(that, column, x) :
+ column.converter.to(x[column.id]);
+ try {
+ a = $(a).text();
+ } catch (e) {}
+ b = ($.isFunction(column.formatter)) ?
+ column.formatter.call(that, column, y) :
+ column.converter.to(y[column.id]);
+ try {
+ b = $(b).text();
+ } catch (e) {}
+ }
+
+ if (that.options.caseSensitive) {
+ a = $.type(a) === 'string' ? a.toLowerCase() : a;
+ b = $.type(b) === 'string' ? b.toLowerCase() : b;
+ }
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
@@ -879,8 +908,6 @@ function sortRows() {
}
if (!this.options.ajax || !this.options.dataFunc) {
- var that = this;
-
for (var key in this.sortDictionary) {
if (this.options.multiSort || sortArray.length === 0) {
sortArray.push({
diff --git a/src/public.js b/src/public.js
index 83a1bc0..765f122 100644
--- a/src/public.js
+++ b/src/public.js
@@ -270,7 +270,28 @@ Grid.defaults = {
// default converter
from: function (value) { return value; },
to: function (value) { return value; }
- }
+ },
+ derived: {
+ // applies reference column converter to each row
+ to: function(val, row, column, grid) {
+ try {
+ var rows = column.rows.split(',');
+ var self = grid;
+ var compiledRows = [];
+ $.each(rows, function(index, element) {
+ var column = self.getColumnSettings({id: element})[0];
+ var content = column.converter.to(row[column.id]);
+ compiledRows.push(content);
+ });
+ return compiledRows.join('');
+ } catch (e) {
+ return val;
+ }
+ },
+ from: function(val) {
+ return val;
+ }
+ }
},
/**
@@ -344,7 +365,31 @@ Grid.defaults = {
* @for defaults
* @since 1.0.0
**/
- formatters: {},
+ formatters: {
+ 'derived': function(column, row) {
+ try {
+ var rows = column.rows.split(',');
+ var self = this;
+ var compiledRows = [];
+ $.each(rows, function(index, element) {
+ var content = row[element];
+ var template = element.template || '__data__
';
+ var column = self.getColumnSettings({id: element})[0];
+ if (element.formatter || column.formatter) {
+ var formatter = column.formatter || element.formatter;
+ content = ($.isFunction(formatter)) ?
+ formatter.call(self, column, row) :
+ column.converter.to(row[column.id]);
+ }
+ var data = template.replace('__data__', content);
+ compiledRows.push(data);
+ });
+ return compiledRows.join('');
+ } catch (e) {
+ return row[column.id];
+ }
+ }
+ },
/**
* Contains all labels.
From a2ba4c0e6fa9e59483d847c96e53fd0432121696 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Fri, 30 Sep 2016 11:53:09 -0700
Subject: [PATCH 07/23] Fix search to ensure value is string
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 6 +++---
src/internal.js | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index a170671..8ac8510 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/30/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 7d29397..b18f2ed 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/30/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 948d604..a2588b3 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/01/2016
+ * jQuery Bootgrid v1.4.2 - 09/30/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -160,7 +160,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id]).search(searchPattern) > -1) {
+ column.converter.to(row[column.id], row).toString().search(searchPattern) > -1) {
return true;
}
}
@@ -603,7 +603,7 @@ function renderRows(rows) {
if (column.visible) {
var value = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, row) :
- column.converter.to(row[column.id]),
+ column.converter.to(row[column.id], row),
cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
cells += tpl.cell.resolve(getParams.call(that, {
content: (value == null || value === "") ? " " : value,
diff --git a/src/internal.js b/src/internal.js
index 83d1b93..412a6fa 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -150,7 +150,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id], row).search(searchPattern) > -1) {
+ column.converter.to(row[column.id], row).toString().search(searchPattern) > -1) {
return true;
}
}
From f3e61ec9251fb5de0570a13c344f03c3e4dd058b Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Thu, 3 Nov 2016 08:52:33 -0700
Subject: [PATCH 08/23] Maintain data properties for rows
---
demo/index.htm | 2 +-
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 3 ++-
src/internal.js | 1 +
5 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/demo/index.htm b/demo/index.htm
index 266fe24..bb5d015 100644
--- a/demo/index.htm
+++ b/demo/index.htm
@@ -94,7 +94,7 @@
-
+
| 1 |
Aimee Delaney |
erat.vitae@estvitaesodales.com |
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 8ac8510..699f8e1 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/30/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index b18f2ed..e7e495a 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/30/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index a2588b3..cc019dc 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/30/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -262,6 +262,7 @@ function loadRows() {
cells = $this.children("td"),
row = {};
+ row['data'] = $this.data();
$.each(that.columns, function(i, column) {
row[column.id] = column.converter.from(cells.eq(i).text());
});
diff --git a/src/internal.js b/src/internal.js
index 412a6fa..4b40c49 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -252,6 +252,7 @@ function loadRows() {
cells = $this.children("td"),
row = {};
+ row['data'] = $this.data();
$.each(that.columns, function(i, column) {
row[column.id] = column.converter.from(cells.eq(i).text());
});
From 875c3f23f166bc9cfdbbadd8074d754ab1144315 Mon Sep 17 00:00:00 2001
From: awestbro
Date: Thu, 3 Nov 2016 15:30:43 -0400
Subject: [PATCH 09/23] Appended rows now get run through the column converter
---
demo/append.html | 157 ++++++++++++++++++++++++++++++++++++++++
dist/jquery.bootgrid.js | 9 ++-
src/public.js | 9 ++-
3 files changed, 171 insertions(+), 4 deletions(-)
create mode 100644 demo/append.html
diff --git a/demo/append.html b/demo/append.html
new file mode 100644
index 0000000..be57c0c
--- /dev/null
+++ b/demo/append.html
@@ -0,0 +1,157 @@
+
+
+
+
+
+ jQuery Bootgrid Demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | ID |
+
+
+
+ | 1111 |
+ | 2222 |
+ | 3333 |
+ | 11111 |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index cc019dc..37f2f86 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1366,9 +1366,14 @@ Grid.prototype.append = function(rows)
var appendedRows = [];
for (var i = 0; i < rows.length; i++)
{
- if (appendRow.call(this, rows[i]))
+ var row = rows[i];
+ for (var j = 0; j < this.columns.length; j++) {
+ var column = this.columns[j];
+ row[column.id] = column.converter.from(row[column.id]);
+ }
+ if (appendRow.call(this, row))
{
- appendedRows.push(rows[i]);
+ appendedRows.push(row);
}
}
sortRows.call(this);
diff --git a/src/public.js b/src/public.js
index 83a1bc0..893824c 100644
--- a/src/public.js
+++ b/src/public.js
@@ -457,9 +457,14 @@ Grid.prototype.append = function(rows)
var appendedRows = [];
for (var i = 0; i < rows.length; i++)
{
- if (appendRow.call(this, rows[i]))
+ var row = rows[i];
+ for (var j = 0; j < this.columns.length; j++) {
+ var column = this.columns[j];
+ row[column.id] = column.converter.from(row[column.id]);
+ }
+ if (appendRow.call(this, row))
{
- appendedRows.push(rows[i]);
+ appendedRows.push(row);
}
}
sortRows.call(this);
From 85fafcf5e2fb5d31da026ea468c50a8e9e8121bc Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Thu, 3 Nov 2016 13:59:18 -0700
Subject: [PATCH 10/23] Build dist
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 15 ++++-----------
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index c6f618f..699f8e1 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/20/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 423d5c1..e7e495a 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/20/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index acd733f..3e7d6d7 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 09/20/2016
+ * jQuery Bootgrid v1.4.2 - 11/03/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -162,8 +162,8 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
- if (column.searchable && (column.visible || that.options.searchSettings.includeHidden) &&
- column.converter.to(row[column.id], row, column, that).search(searchPattern) > -1) {
+ if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
+ column.converter.to(row[column.id], row).toString().search(searchPattern) > -1) {
return true;
}
}
@@ -607,7 +607,7 @@ function renderRows(rows) {
if (column.visible) {
var value = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, row) :
- column.converter.to(row[column.id], row),
+ column.converter.to(row[column.id], row, column, that),
cssClass = (column.cssClass.length > 0) ? " " + column.cssClass : "";
cells += tpl.cell.resolve(getParams.call(that, {
content: (value == null || value === "") ? " " : value,
@@ -913,13 +913,6 @@ function sortRows() {
b = $.type(b) === 'string' ? b.toLowerCase() : b;
}
- // if column has a converter, use it
- var col = that.getColumnSettings({id: item.id});
- if(col.length > 0){
- a = col[0].converter ? col[0].converter.to(a, x) : a;
- b = col[0].converter ? col[0].converter.to(b, y) : b;
- }
-
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
(sortArray.length > next) ? sort(x, y, next) : 0;
From 5bde561d0d898ee4727710e4477423d0581d788a Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Thu, 3 Nov 2016 14:08:08 -0700
Subject: [PATCH 11/23] Ensure string value before tolowercase
---
dist/jquery.bootgrid.js | 8 ++++++--
src/internal.js | 8 ++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 37f2f86..f7dec48 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -874,8 +874,12 @@ function sortRows() {
return (item.order === "asc") ? value : value * -1;
}
- var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
- var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ var a = x[item.id] || '';
+ var b = y[item.id] || '';
+ if (that.options.caseSensitive) {
+ a = $.type(a) === 'string' ? a.toLowerCase() : a;
+ b = $.type(b) === 'string' ? b.toLowerCase() : b;
+ }
// if column has a converter, use it
var col = that.getColumnSettings({id: item.id});
diff --git a/src/internal.js b/src/internal.js
index 4b40c49..dbb1033 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -864,8 +864,12 @@ function sortRows() {
return (item.order === "asc") ? value : value * -1;
}
- var a = that.options.caseSensitive ? x[item.id] : x[item.id].toLowerCase();
- var b = that.options.caseSensitive ? y[item.id] : y[item.id].toLowerCase();
+ var a = x[item.id] || '';
+ var b = y[item.id] || '';
+ if (that.options.caseSensitive) {
+ a = $.type(a) === 'string' ? a.toLowerCase() : a;
+ b = $.type(b) === 'string' ? b.toLowerCase() : b;
+ }
// if column has a converter, use it
var col = that.getColumnSettings({id: item.id});
From b31862713487ba7c937c17f5e6bdb8f65be6885f Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Mon, 7 Nov 2016 08:06:19 -0800
Subject: [PATCH 12/23] Optionally render refresh button when using ajax
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 16 +++++++++++++---
src/internal.js | 2 +-
src/public.js | 12 +++++++++++-
5 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 699f8e1..00adeb0 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 11/07/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index e7e495a..537204c 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 11/07/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index f7dec48..3a58d8c 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 11/07/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -320,7 +320,7 @@ function renderActions() {
actions = $(tpl.actions.resolve(getParams.call(this)));
// Refresh Button
- if (this.options.ajax || this.options.dataFunc) {
+ if ((this.options.ajax || this.options.dataFunc) && this.options.ajaxSettings.includeRefresh) {
var refreshIcon = tpl.icon.resolve(getParams.call(this, {
iconCss: css.iconRefresh
})),
@@ -1105,7 +1105,17 @@ Grid.defaults = {
* @default "POST"
* @for ajaxSettings
**/
- method: "POST"
+ method: "POST",
+
+ /**
+ * Option if refresh button should be shown
+ *
+ * @property includeRefresh
+ * @type Boolean
+ * @default true
+ * @for ajaxSettings
+ **/
+ includeRefresh: true
},
/**
diff --git a/src/internal.js b/src/internal.js
index dbb1033..139ab12 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -310,7 +310,7 @@ function renderActions() {
actions = $(tpl.actions.resolve(getParams.call(this)));
// Refresh Button
- if (this.options.ajax || this.options.dataFunc) {
+ if ((this.options.ajax || this.options.dataFunc) && this.options.ajaxSettings.includeRefresh) {
var refreshIcon = tpl.icon.resolve(getParams.call(this, {
iconCss: css.iconRefresh
})),
diff --git a/src/public.js b/src/public.js
index 893824c..7915c02 100644
--- a/src/public.js
+++ b/src/public.js
@@ -192,7 +192,17 @@ Grid.defaults = {
* @default "POST"
* @for ajaxSettings
**/
- method: "POST"
+ method: "POST",
+
+ /**
+ * Option if refresh button should be shown
+ *
+ * @property includeRefresh
+ * @type Boolean
+ * @default true
+ * @for ajaxSettings
+ **/
+ includeRefresh: true
},
/**
From 1522d32d0e2c31bbed16d454b706159aa73618eb Mon Sep 17 00:00:00 2001
From: DavidMove
Date: Wed, 14 Dec 2016 16:29:13 -0800
Subject: [PATCH 13/23] Fixed converter sort issue.
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 12 ++++++------
src/internal.js | 10 +++++-----
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 00adeb0..72c96c5 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/07/2016
+ * jQuery Bootgrid v1.4.2 - 12/14/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 537204c..2a98bbc 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/07/2016
+ * jQuery Bootgrid v1.4.2 - 12/14/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 3a58d8c..575bb02 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/07/2016
+ * jQuery Bootgrid v1.4.2 - 12/14/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -882,11 +882,11 @@ function sortRows() {
}
// if column has a converter, use it
- var col = that.getColumnSettings({id: item.id});
- if(col.length > 0){
- a = col[0].converter ? col[0].converter.to(a, x) : a;
- b = col[0].converter ? col[0].converter.to(b, y) : b;
- }
+ var col = that.getColumnSettings({id: item.id});
+ if(col.length > 0){
+ a = col[0].converter ? col[0].converter.from(a, x) : a;
+ b = col[0].converter ? col[0].converter.from(b, y) : b;
+ }
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
diff --git a/src/internal.js b/src/internal.js
index 139ab12..587ae2c 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -872,11 +872,11 @@ function sortRows() {
}
// if column has a converter, use it
- var col = that.getColumnSettings({id: item.id});
- if(col.length > 0){
- a = col[0].converter ? col[0].converter.to(a, x) : a;
- b = col[0].converter ? col[0].converter.to(b, y) : b;
- }
+ var col = that.getColumnSettings({id: item.id});
+ if(col.length > 0){
+ a = col[0].converter ? col[0].converter.from(a, x) : a;
+ b = col[0].converter ? col[0].converter.from(b, y) : b;
+ }
return (a > b) ? sortOrder(1) :
(a < b) ? sortOrder(-1) :
From 858f7466a055c297b14b28e959e6d7996fadbe99 Mon Sep 17 00:00:00 2001
From: DavidMove
Date: Tue, 20 Dec 2016 14:38:51 -0800
Subject: [PATCH 14/23] Fixed derived column sort/search and added avatar
example.
---
demo/derived.htm | 98 ++++++++++++++++++++++++--------------
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 8 ++--
src/internal.js | 6 +--
5 files changed, 72 insertions(+), 44 deletions(-)
diff --git a/demo/derived.htm b/demo/derived.htm
index 28813e6..92ed217 100644
--- a/demo/derived.htm
+++ b/demo/derived.htm
@@ -79,77 +79,71 @@
- | ID |
- Name |
+ ID |
+ Avatar |
+ Name |
Sender |
Received |
Company |
Cost |
-
- Derived
- |
+ Derived |
Hidden |
| 1 |
- {"text": "Aimee Delaney", "url":"http://www.aaa.ca"} |
- erat.vitae@estvitaesodales.com |
+ |
+ Aimee Delaney |
+ |
03.06.16 |
Maecenas Malesuada Foundation |
222222 |
-
-
- |
+ |
C9F35176-EE9C-7DA5-DB47-5B62C57AA176 |
| 2 |
+ http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "BORIS BULE", "url": "http://www.zzz.ca"} |
vitae.diam@Proinultrices.edu |
10.12.16 |
Ac Corporation |
11111111 |
-
-
- |
+ |
1BC83AA2-0979-C426-A3B4-4CC4F8B0CFF9 |
| 3 |
+ http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "ALEX Reese", "url": "http://www.ccc.com"} |
mauris.sit.amet@nonmassa.ca |
27.06.17 |
Nulla At Incorporated |
333333333 |
-
-
- |
+ |
C3CF97AE-0E0E-EA4E-FBF5-A63444134B8E |
| 4 |
+ http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "Juliet Mcfarland", "url": "http://www.eee.com"} |
egestas.Duis.ac@eu.net |
02.07.16 |
Nisi Sem Semper Limited |
555555 |
-
-
- |
+ |
33AC322B-8AB4-B9F0-FAF0-BD69A7937627 |
| 5 |
+ http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"url": "http://www.ddd.com", "text": "Aaron Weaver"} |
Curabitur@fermentumconvallisligula.org |
07.06.17 |
Magna Nec Quam Industries |
4444444 |
-
-
- |
+ |
235B6F73-2150-A423-DC0A-A75C74669824 |
@@ -195,25 +189,59 @@
link = $.extend(true, {}, defaults, options);
return '' + link.text + '';
} catch (e) {
- console.log(e);
return row[column.id];
}
+ },
+ // Fixed column: Media object with media-object and text
+ 'avatar': function(column, row) {
+ try {
+ var rows = column.rows.split(',');
+ var self = this;
+ var compiledRows = [];
+ var $avatarMarkup = $('');
+ var imgMarkup = '';
+ if (row[column.id] == '') {
+ imgMarkup = '';
+ }
+ $avatarMarkup.find('.media').prepend(imgMarkup);
+
+ $.each(rows, function(index, element) {
+ var content = row[element];
+ var template = element.template || '__data__
';
+ var column = self.getColumnSettings({id: element})[0];
+
+ if (element.formatter || column.formatter) {
+ var formatter = column.formatter || element.formatter;
+ content = ($.isFunction(formatter)) ?
+ formatter.call(self, column, row) :
+ column.converter.to(row[column.id]);
+ }
+ var data = template.replace('__data__', content);
+ compiledRows.push(data);
+ });
+
+ $avatarMarkup.find('.media-left').append(compiledRows.join(''));
+
+ return $avatarMarkup.html();
+ } catch (e) {
+ return row[column.id];
+ }
}
},
converters: {
- link: {
- to: function(val, row, column, that){
- try{
- val = JSON.parse(val);
- return val.text;
- }catch(e){
- return val;
- }
- },
- from: function(val){
- return val;
- }
+ link: {
+ to: function(val, row, column, that){
+ try{
+ val = JSON.parse(val);
+ return val.text;
+ }catch(e){
+ return val;
}
+ },
+ from: function(val){
+ return val;
+ }
+ }
},
caseSensitive: true,
rowCount: [-1, 5, 10, 15],
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 699f8e1..d7011f7 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 12/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index e7e495a..13ea238 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 12/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 3e7d6d7..bc70a76 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 11/03/2016
+ * jQuery Bootgrid v1.4.2 - 12/20/2016
* Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -163,7 +163,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id], row).toString().search(searchPattern) > -1) {
+ column.converter.to(row[column.id], row, column, that).toString().search(searchPattern) > -1) {
return true;
}
}
@@ -898,13 +898,13 @@ function sortRows() {
column.formatter.call(that, column, x) :
column.converter.to(x[column.id]);
try {
- a = $(a).text();
+ a = $(a).text() || a;
} catch (e) {}
b = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, y) :
column.converter.to(y[column.id]);
try {
- b = $(b).text();
+ b = $(b).text() || b;
} catch (e) {}
}
diff --git a/src/internal.js b/src/internal.js
index b94402f..45c33e2 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -153,7 +153,7 @@ function loadData() {
for (var i = 0; i < that.columns.length; i++) {
column = that.columns[i];
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden ) &&
- column.converter.to(row[column.id], row).toString().search(searchPattern) > -1) {
+ column.converter.to(row[column.id], row, column, that).toString().search(searchPattern) > -1) {
return true;
}
}
@@ -888,13 +888,13 @@ function sortRows() {
column.formatter.call(that, column, x) :
column.converter.to(x[column.id]);
try {
- a = $(a).text();
+ a = $(a).text() || a;
} catch (e) {}
b = ($.isFunction(column.formatter)) ?
column.formatter.call(that, column, y) :
column.converter.to(y[column.id]);
try {
- b = $(b).text();
+ b = $(b).text() || b;
} catch (e) {}
}
From 082db7bf39943b7f6a729e86df0ef7e7616dc892 Mon Sep 17 00:00:00 2001
From: DavidMove
Date: Wed, 21 Dec 2016 09:16:53 -0800
Subject: [PATCH 15/23] Removed avatar from derived demo file.
---
demo/derived.htm | 41 -----------------------------------------
1 file changed, 41 deletions(-)
diff --git a/demo/derived.htm b/demo/derived.htm
index 92ed217..ad63f52 100644
--- a/demo/derived.htm
+++ b/demo/derived.htm
@@ -80,7 +80,6 @@
| ID |
- Avatar |
Name |
Sender |
Received |
@@ -93,7 +92,6 @@
| 1 |
- |
Aimee Delaney |
|
03.06.16 |
@@ -104,7 +102,6 @@
| 2 |
- http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "BORIS BULE", "url": "http://www.zzz.ca"} |
vitae.diam@Proinultrices.edu |
10.12.16 |
@@ -115,7 +112,6 @@
| 3 |
- http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "ALEX Reese", "url": "http://www.ccc.com"} |
mauris.sit.amet@nonmassa.ca |
27.06.17 |
@@ -126,7 +122,6 @@
| 4 |
- http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"text": "Juliet Mcfarland", "url": "http://www.eee.com"} |
egestas.Duis.ac@eu.net |
02.07.16 |
@@ -137,7 +132,6 @@
| 5 |
- http://www.gefsgpegypt.org/Portals/0/empty_profile.gif |
{"url": "http://www.ddd.com", "text": "Aaron Weaver"} |
Curabitur@fermentumconvallisligula.org |
07.06.17 |
@@ -191,41 +185,6 @@
} catch (e) {
return row[column.id];
}
- },
- // Fixed column: Media object with media-object and text
- 'avatar': function(column, row) {
- try {
- var rows = column.rows.split(',');
- var self = this;
- var compiledRows = [];
- var $avatarMarkup = $('');
- var imgMarkup = '';
- if (row[column.id] == '') {
- imgMarkup = '';
- }
- $avatarMarkup.find('.media').prepend(imgMarkup);
-
- $.each(rows, function(index, element) {
- var content = row[element];
- var template = element.template || '__data__
';
- var column = self.getColumnSettings({id: element})[0];
-
- if (element.formatter || column.formatter) {
- var formatter = column.formatter || element.formatter;
- content = ($.isFunction(formatter)) ?
- formatter.call(self, column, row) :
- column.converter.to(row[column.id]);
- }
- var data = template.replace('__data__', content);
- compiledRows.push(data);
- });
-
- $avatarMarkup.find('.media-left').append(compiledRows.join(''));
-
- return $avatarMarkup.html();
- } catch (e) {
- return row[column.id];
- }
}
},
converters: {
From 6e07259cc1977b1210b2ca40a4181d644a8165d6 Mon Sep 17 00:00:00 2001
From: DavidMove
Date: Wed, 21 Dec 2016 09:18:24 -0800
Subject: [PATCH 16/23] Took out data-visible=false on name column in derived
example.
---
demo/derived.htm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/demo/derived.htm b/demo/derived.htm
index ad63f52..a1fc66c 100644
--- a/demo/derived.htm
+++ b/demo/derived.htm
@@ -80,7 +80,7 @@
| ID |
- Name |
+ Name |
Sender |
Received |
Company |
From e1dcb62bee454d25b9e115d086d1e3bcf3fc4334 Mon Sep 17 00:00:00 2001
From: awestbro
Date: Tue, 10 Jan 2017 15:45:26 -0500
Subject: [PATCH 17/23] Flipped case sensitivity logic for sortable string
columns
---
dist/jquery.bootgrid.css | 4 ++--
dist/jquery.bootgrid.fa.js | 4 ++--
dist/jquery.bootgrid.js | 6 +++---
src/internal.js | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index d7011f7..c845a01 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,6 +1,6 @@
/*!
- * jQuery Bootgrid v1.4.2 - 12/20/2016
- * Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
+ * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
.bootgrid-header,
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 13ea238..26f317b 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,6 +1,6 @@
/*!
- * jQuery Bootgrid v1.4.2 - 12/20/2016
- * Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
+ * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
;(function ($, window, undefined)
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index ed7112f..e012c2c 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,6 +1,6 @@
/*!
- * jQuery Bootgrid v1.4.2 - 12/20/2016
- * Copyright (c) 2014-2016 Rafael Staib (http://www.jquery-bootgrid.com)
+ * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
;(function ($, window, undefined)
@@ -908,7 +908,7 @@ function sortRows() {
} catch (e) {}
}
- if (that.options.caseSensitive) {
+ if (!that.options.caseSensitive) {
a = $.type(a) === 'string' ? a.toLowerCase() : a;
b = $.type(b) === 'string' ? b.toLowerCase() : b;
}
diff --git a/src/internal.js b/src/internal.js
index ad0bbb6..7d37bcd 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -898,7 +898,7 @@ function sortRows() {
} catch (e) {}
}
- if (that.options.caseSensitive) {
+ if (!that.options.caseSensitive) {
a = $.type(a) === 'string' ? a.toLowerCase() : a;
b = $.type(b) === 'string' ? b.toLowerCase() : b;
}
From 641ae997bdf0c40dc3e29ed45a46fd91ba842de4 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Fri, 13 Jan 2017 09:43:09 -0800
Subject: [PATCH 18/23] add sort event trigger
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 4 +++-
src/internal.js | 2 ++
4 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index c845a01..3249fec 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * jQuery Bootgrid v1.4.2 - 01/13/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index 26f317b..d659881 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * jQuery Bootgrid v1.4.2 - 01/13/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index e012c2c..9d5c652 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/10/2017
+ * jQuery Bootgrid v1.4.2 - 01/13/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -869,6 +869,8 @@ function sortRows() {
var that = this;
var sortArray = [];
+ that.element.trigger('sort', that.getSortDictionary());
+
function sort(x, y, current) {
current = current || 0;
var next = current + 1,
diff --git a/src/internal.js b/src/internal.js
index 7d37bcd..8d8a3bc 100644
--- a/src/internal.js
+++ b/src/internal.js
@@ -859,6 +859,8 @@ function sortRows() {
var that = this;
var sortArray = [];
+ that.element.trigger('sort', that.getSortDictionary());
+
function sort(x, y, current) {
current = current || 0;
var next = current + 1,
From 7a56086079cf17b9d4febede10a751ed3c7a927c Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Fri, 20 Jan 2017 08:58:09 -0800
Subject: [PATCH 19/23] added defaultRowCount parameter
---
CHANGELOG.md | 6 ++++++
src/public.js | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acf6b3d..278ce3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## Unreleased
+
+### Enhancements & Features
+- Add `defaultRowCount` property to set default row count from rowCount array
+- Add `sort` event; triggered when column is sorted
+
## 1.4.3
### Enhancements & Features
diff --git a/src/public.js b/src/public.js
index f606cc6..3399ab6 100644
--- a/src/public.js
+++ b/src/public.js
@@ -23,7 +23,11 @@ var Grid = function(element, options)
this.identifier = null; // The first column ID that is marked as identifier
this.selection = false;
this.converter = null; // The converter for the column that is marked as identifier
- this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount;
+ this.rowCount = rowCount;
+ if($.isArray(rowCount)){
+ var defaultRowCount = this.options.defaultRowCount = this.element.data().defaultRowCount || options.defaultRowCount || this.options.defaultRowCount;
+ this.rowCount = (rowCount.indexOf(defaultRowCount) > -1) ? defaultRowCount : rowCount[0];
+ };
this.rows = [];
this.searchPhrase = "";
this.selectedRows = [];
From c12f1df58d76a5c0fe10c9e46e4eb7e34eb24196 Mon Sep 17 00:00:00 2001
From: Matt Groth
Date: Fri, 20 Jan 2017 09:01:08 -0800
Subject: [PATCH 20/23] build dist
---
dist/jquery.bootgrid.css | 2 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 8 ++++++--
src/public.js | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css
index 3249fec..c6593f4 100644
--- a/dist/jquery.bootgrid.css
+++ b/dist/jquery.bootgrid.css
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/13/2017
+ * jQuery Bootgrid v1.4.2 - 01/20/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.fa.js b/dist/jquery.bootgrid.fa.js
index d659881..ba6ac6d 100644
--- a/dist/jquery.bootgrid.fa.js
+++ b/dist/jquery.bootgrid.fa.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/13/2017
+ * jQuery Bootgrid v1.4.2 - 01/20/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js
index 9d5c652..5ac87e3 100644
--- a/dist/jquery.bootgrid.js
+++ b/dist/jquery.bootgrid.js
@@ -1,5 +1,5 @@
/*!
- * jQuery Bootgrid v1.4.2 - 01/13/2017
+ * jQuery Bootgrid v1.4.2 - 01/20/2017
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
* Licensed under MIT http://www.opensource.org/licenses/MIT
*/
@@ -961,7 +961,11 @@ var Grid = function(element, options)
this.identifier = null; // The first column ID that is marked as identifier
this.selection = false;
this.converter = null; // The converter for the column that is marked as identifier
- this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount;
+ this.rowCount = rowCount;
+ if($.isArray(rowCount)){
+ var defaultRowCount = this.options.defaultRowCount = this.element.data().defaultRowCount || options.defaultRowCount || this.options.defaultRowCount;
+ this.rowCount = (rowCount.indexOf(defaultRowCount) > -1) ? defaultRowCount : rowCount[0];
+ }
this.rows = [];
this.searchPhrase = "";
this.selectedRows = [];
diff --git a/src/public.js b/src/public.js
index 3399ab6..43c33d1 100644
--- a/src/public.js
+++ b/src/public.js
@@ -27,7 +27,7 @@ var Grid = function(element, options)
if($.isArray(rowCount)){
var defaultRowCount = this.options.defaultRowCount = this.element.data().defaultRowCount || options.defaultRowCount || this.options.defaultRowCount;
this.rowCount = (rowCount.indexOf(defaultRowCount) > -1) ? defaultRowCount : rowCount[0];
- };
+ }
this.rows = [];
this.searchPhrase = "";
this.selectedRows = [];
From 260098c1796add22796de1395d56c75c40398c1f Mon Sep 17 00:00:00 2001
From: DavidMove
Date: Thu, 9 Feb 2017 13:53:49 -0800
Subject: [PATCH 21/23] Added text highlighting to search results
---
CHANGELOG.md | 3 +
demo/index.htm | 1055 ++++++++++++++++++------------------
dist/jquery.bootgrid.css | 5 +-
dist/jquery.bootgrid.fa.js | 2 +-
dist/jquery.bootgrid.js | 66 ++-
src/internal.js | 47 +-
src/jquery.bootgrid.less | 9 +-
src/public.js | 17 +-
8 files changed, 666 insertions(+), 538 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 278ce3e..7bbaf98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@
### Enhancements & Features
- Add `defaultRowCount` property to set default row count from rowCount array
- Add `sort` event; triggered when column is sorted
+- Add `searchSettings.highlightResults` option to wrap matching substrings that match the query in result set
+ - Add `highlightResults` css class to options
+ - Add `highlightResults` template which wraps the matched substring
## 1.4.3
diff --git a/demo/index.htm b/demo/index.htm
index bb5d015..ed4dd00 100644
--- a/demo/index.htm
+++ b/demo/index.htm
@@ -1,559 +1,564 @@
-
-
-
- jQuery Bootgrid Demo
-
-
-
-
-
-
-