Permalink
Browse files

Fix for #531 and #533

  • Loading branch information...
1 parent d7c665a commit 8017eee035ac21ce9989eb26ea5dc6c13b9553cd @jonricaurte jonricaurte committed Jul 6, 2013
Showing with 421 additions and 298 deletions.
  1. +104 −74 build/ng-grid.debug.js
  2. +103 −71 build/ng-grid.js
  3. +2 −2 build/ng-grid.min.js
  4. +104 −74 ng-grid-2.0.7.debug.js
  5. +2 −2 ng-grid-2.0.7.min.js
  6. +2 −2 src/classes/grid.js
  7. +18 −16 src/classes/rowFactory.js
  8. +83 −55 src/classes/searchProvider.js
  9. +3 −2 workbench/main3.js
View
@@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
-* Compiled At: 07/02/2013 23:01
+* Compiled At: 07/06/2013 13:50
***********************************************/
(function(window, $) {
'use strict';
@@ -1597,8 +1597,8 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
cols.push(column);
});
$scope.columns = cols;
- if ($scope.configGroups.length > 0) {
- self.rowFactory.getGrouping($scope.configGroups);
+ if (self.config.groups.length > 0) {
+ self.rowFactory.getGrouping(self.config.groups);
}
}
};
@@ -2431,23 +2431,25 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
}
//moved out of above loops due to if no data initially, but has initial grouping, columns won't be added
- for (var z = 0; z < groups.length; z++) {
- if (!cols[z].isAggCol && z <= maxDepth) {
- cols.splice(0, 0, new ngColumn({
- colDef: {
- field: '',
- width: 25,
- sortable: false,
- resizable: false,
- headerCellTemplate: '<div class="ngAggHeader"></div>',
- pinned: grid.config.pinSelectionCheckbox
+ if(cols.length > 0) {
+ for (var z = 0; z < groups.length; z++) {
+ if (!cols[z].isAggCol && z <= maxDepth) {
+ cols.splice(0, 0, new ngColumn({
+ colDef: {
+ field: '',
+ width: 25,
+ sortable: false,
+ resizable: false,
+ headerCellTemplate: '<div class="ngAggHeader"></div>',
+ pinned: grid.config.pinSelectionCheckbox
+
+ },
+ enablePinning: grid.config.enablePinning,
+ isAggCol: true,
+ headerRowHeight: grid.config.headerRowHeight
- },
- enablePinning: grid.config.enablePinning,
- isAggCol: true,
- headerRowHeight: grid.config.headerRowHeight
-
- }, $scope, grid, domUtilityService, $templateCache, $utils));
+ }, $scope, grid, domUtilityService, $templateCache, $utils));
+ }
}
}
@@ -2472,65 +2474,83 @@ var ngSearchProvider = function ($scope, grid, $filter) {
self.fieldMap = {};
- self.evalFilter = function () {
- var filterFunc = function(item) {
- for (var x = 0, len = searchConditions.length; x < len; x++) {
- var condition = searchConditions[x];
- //Search entire row
- var result;
- if (!condition.column) {
- for (var prop in item) {
- if (item.hasOwnProperty(prop)) {
- var c = self.fieldMap[prop.toLowerCase()];
- if (!c) {
- continue;
- }
- var f = null,
- s = null;
- if (c && c.cellFilter) {
- s = c.cellFilter.split(':');
- f = $filter(s[0]);
- }
- var pVal = item[prop];
- if (pVal !== null && pVal !== undefined) {
- if (typeof f === "function") {
- var filterRes = f(typeof pVal === 'object' ? evalObject(pVal, c.field) : pVal, s[1]).toString();
- result = condition.regex.test(filterRes);
- } else {
- result = condition.regex.test(typeof pVal === 'object' ? evalObject(pVal, c.field).toString() : pVal.toString());
- }
- if (result) {
- return true;
- }
- }
+ var searchEntireRow = function(condition, item, fieldMap){
+ var result;
+ for (var prop in item) {
+ if (item.hasOwnProperty(prop)) {
+ var c = fieldMap[prop.toLowerCase()];
+ if (!c) {
+ continue;
+ }
+ var pVal = item[prop];
+ if(typeof pVal === 'object'){
+ return searchEntireRow(condition, pVal, c);
+ } else {
+ var f = null,
+ s = null;
+ if (c && c.cellFilter) {
+ s = c.cellFilter.split(':');
+ f = $filter(s[0]);
+ }
+ if (pVal !== null && pVal !== undefined) {
+ if (typeof f === "function") {
+ var filterRes = f(pVal, s[1]).toString();
+ result = condition.regex.test(filterRes);
+ } else {
+ result = condition.regex.test(pVal.toString());
+ }
+ if (result) {
+ return true;
}
}
- return false;
- }
- //Search by column.
- var col = self.fieldMap[condition.columnDisplay];
- if (!col) {
- return false;
- }
- var sp = col.cellFilter.split(':');
- var filter = col.cellFilter ? $filter(sp[0]) : null;
- var value = item[condition.column] || item[col.field.split('.')[0]];
- if (value === null || value === undefined) {
- return false;
- }
- if (typeof filter === "function") {
- var filterResults = filter(typeof value === "object" ? evalObject(value, col.field) : value, sp[1]).toString();
- result = condition.regex.test(filterResults);
- }
- else {
- result = condition.regex.test(typeof value === "object" ? evalObject(value, col.field).toString() : value.toString());
- }
- if (!result) {
- return false;
}
}
+ }
+ return false;
+ };
+
+ var searchColumn = function(condition, item){
+ var result;
+ var col = self.fieldMap[condition.columnDisplay];
+ if (!col) {
+ return false;
+ }
+ var sp = col.cellFilter.split(':');
+ var filter = col.cellFilter ? $filter(sp[0]) : null;
+ var value = item[condition.column] || item[col.field.split('.')[0]];
+ if (value === null || value === undefined) {
+ return false;
+ }
+ if (typeof filter === "function") {
+ var filterResults = filter(typeof value === "object" ? evalObject(value, col.field) : value, sp[1]).toString();
+ result = condition.regex.test(filterResults);
+ }
+ else {
+ result = condition.regex.test(typeof value === "object" ? evalObject(value, col.field).toString() : value.toString());
+ }
+ if (result) {
return true;
- };
+ }
+ return false;
+ };
+
+ var filterFunc = function(item) {
+ for (var x = 0, len = searchConditions.length; x < len; x++) {
+ var condition = searchConditions[x];
+ var result;
+ if (!condition.column) {
+ result = searchEntireRow(condition, item, self.fieldMap);
+ } else {
+ result = searchColumn(condition, item);
+ }
+ if(!result) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ self.evalFilter = function () {
if (searchConditions.length === 0) {
grid.filteredRows = grid.rowCache;
} else {
@@ -2609,7 +2629,17 @@ var ngSearchProvider = function ($scope, grid, $filter) {
for (var i = 0; i < cs.length; i++) {
var col = cs[i];
if (col.field) {
- self.fieldMap[col.field.split('.')[0].toLowerCase()] = col;
+ if(col.field.match(/\./g)){
+ var properties = col.field.split('.');
+ var currentProperty = self.fieldMap;
+ for(var j = 0; j < properties.length - 1; j++) {
+ currentProperty[ properties[j] ] = currentProperty[ properties[j] ] || {};
+ currentProperty = currentProperty[properties[j]];
+ }
+ currentProperty[ properties[properties.length - 1] ] = col;
+ } else {
+ self.fieldMap[col.field.toLowerCase()] = col;
+ }
}
if (col.displayName) {
self.fieldMap[col.displayName.toLowerCase().replace(/\s+/g, '')] = col;
Oops, something went wrong.

0 comments on commit 8017eee

Please sign in to comment.