From ea680334aa4c8ee8250cebea5f38091980387911 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 24 Aug 2014 09:14:10 +1200 Subject: [PATCH 1/3] Mark functions as methodOf, rather than property --- src/js/core/factories/GridOptions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/core/factories/GridOptions.js b/src/js/core/factories/GridOptions.js index cfed59613a..bfb422393a 100644 --- a/src/js/core/factories/GridOptions.js +++ b/src/js/core/factories/GridOptions.js @@ -73,7 +73,7 @@ angular.module('ui.grid') /** * @ngdoc function * @name rowIdentity - * @propertyOf ui.grid.class:GridOptions + * @methodOf ui.grid.class:GridOptions * @description (optional) This function is used to get and, if necessary, set the value uniquely identifying this row. * * By default it returns the `$$hashKey` property if it exists. If it doesn't it uses gridUtil.nextUid() to generate one @@ -85,7 +85,7 @@ angular.module('ui.grid') /** * @ngdoc function * @name getRowIdentity - * @propertyOf ui.grid.class:GridOptions + * @methodOf ui.grid.class:GridOptions * @description (optional) This function returns the identity value uniquely identifying this row. * * By default it returns the `$$hashKey` property but can be overridden to use any property or set of properties you want. @@ -156,4 +156,4 @@ angular.module('ui.grid') }]); -})(); \ No newline at end of file +})(); From f6ab1cb8e431742854a060e30c55cbdb3b675dfb Mon Sep 17 00:00:00 2001 From: Paul Lambert Date: Sun, 24 Aug 2014 12:39:08 +1200 Subject: [PATCH 2/3] Update tutorials and ngdoc for clarity Update tutorial for filtering to provide an example of setting the filter programmatically. Update the ngDoc for ui.grid:GridOptions to mark functions as @methodOf rather than @propertyOf, which should correctly split these into the methods section of the ui-grid.info site. Update the ngDoc for ui.grid:GridColumns to break the properties out into separate ngDoc blocks, which should make them more easily visible in the ui-grid.info site. Mark these also as @propertyOf ui.grid:GridOptions.columnDefs, which should result in these properties also being visible on columnDefs. --- 3.0_UPGRADE.md | 88 ++++++++++++++++++++++++++-- misc/tutorial/103_filtering.ngdoc | 4 +- src/features/edit/js/gridEdit.js | 4 ++ src/js/core/factories/GridColumn.js | 77 +++++++++++++++++------- src/js/core/factories/GridOptions.js | 74 ++++++++++++++++++----- 5 files changed, 206 insertions(+), 41 deletions(-) diff --git a/3.0_UPGRADE.md b/3.0_UPGRADE.md index a0afcd02b0..7a819a6b48 100644 --- a/3.0_UPGRADE.md +++ b/3.0_UPGRADE.md @@ -1,7 +1,10 @@ Upgrading from ng-grid 2.0.x to ui-grid 3.0 -1. Module name has changed from nggrid to ui.grid - directive name has changed from ng-grid to ui-grid. Before: +## Module name has changed from nggrid to ui.grid + +Directive name has changed from ng-grid to ui-grid. + +Before: ```html
``` @@ -17,7 +20,11 @@ After: angular.module('yourModule', ['ui.grid']; ``` -2. A string value in options.columnDefs is no longer supported. ColumnDefs are now always watched via $watchCollection. Before: +## A string value in options.columnDefs is no longer supported. + +ColumnDefs are now always watched via $watchCollection. + +Before: ```javascript $scope.myColDefs = {[...]}; $scope.gridOptions.columnDefs = 'myColDefs' @@ -25,7 +32,78 @@ $scope.gridOptions.columnDefs = 'myColDefs' After: ```javascript -$scope.gridOptions.columnDefs = $scope.myColDefs = {[...]}; +$scope.gridOptions.columnDefs = $scope.myColDefs = [...]; or -$scope.gridOptions.columnDefs = {[...]}; +$scope.gridOptions.columnDefs = [...]; +``` + +## All columns within columnDefs must have a name or a field. + +Before: +```javascript +$scope.gridOptions = { + columnDefs: [ + { displayName: 'Edit' } + ], + data: myData +}; +``` + +After: +```javascript +$scope.gridOptions = { + columnDefs: [ + { name: 'edit', displayName: 'Edit' } + ], + data: myData +}; +``` + +## ui-grid uses an isolate scope +You can no longer access data or functions directly on the parent scope. You can access a pre-defined scope by using getExternalScopes(), and set this scope using the external-scopes directive. + +Before: +```javascript +$scope.gridOptions = { + columnDefs = [ + { name: 'edit', displayName: 'Edit', cellTemplate: '' } + ], + data: myData +}; + +$scope.edit = function( entity ) { + ...some custom function using entity... +}; +``` + +```html +
+``` + +After: +```javascript +$scope.gridScope = $scope; +$scope.gridOptions = { + columnDefs = [ + { name: 'edit', displayName: 'Edit', cellTemplate: '' } + ], + data: myData +}; + +$scope.edit = function( entity ) { + ...some custom function using entity... +}; +``` + +```html +
+``` + +## Some features previously included in the base are now plugins. + +Refer to the tutorials and API documentation at http://ui-grid.info/docs/ for more detail, an example provided below is column resizing. The plugins are available in the base javascript, using them requires only including the appropriate directive in the grid declaration: + +After: +```html +
``` diff --git a/misc/tutorial/103_filtering.ngdoc b/misc/tutorial/103_filtering.ngdoc index 6a131cd66a..2615a2de80 100644 --- a/misc/tutorial/103_filtering.ngdoc +++ b/misc/tutorial/103_filtering.ngdoc @@ -6,6 +6,8 @@ UI-Grid allows you to filter rows. Just set the `enableFiltering` flag in your g Filtering can be disabled at the column level by setting `enableFiltering: false` in the column def. See the last column below for an example. +Default filters can be set programmatically by setting `filter: { term: 'xxx' }` in the column def. See the second column below. + @example @@ -16,7 +18,7 @@ Filtering can be disabled at the column level by setting `enableFiltering: false enableFiltering: true, columnDefs: [ { field: 'name' }, - { field: 'gender' }, + { field: 'gender', filter: { term: 'male' } }, { field: 'company', enableFiltering: false } ] }; diff --git a/src/features/edit/js/gridEdit.js b/src/features/edit/js/gridEdit.js index b99680967c..1d6a1abdee 100644 --- a/src/features/edit/js/gridEdit.js +++ b/src/features/edit/js/gridEdit.js @@ -102,6 +102,7 @@ * @ngdoc object * @name enableCellEdit * @propertyOf ui.grid.edit.api:GridOptions + * @propertyOf ui.grid.class:GridOptions.columnDef * @description If defined, it will be the default value that colDefs will take if their enableCellEdit is * not defined. Defaults to undefined. */ @@ -110,6 +111,7 @@ * @ngdoc object * @name cellEditableCondition * @propertyOf ui.grid.edit.api:GridOptions + * @propertyOf ui.grid.class:GridOptions.columnDef * @description If specified, either a value or function to be used by all columns before editing. If falsy, then editing of cell is not allowed *
            *  function($scope){
@@ -124,6 +126,7 @@
            *  @ngdoc object
            *  @name editableCellTemplate
            *  @propertyOf  ui.grid.edit.api:GridOptions
+           *  @propertyOf  ui.grid.class:GridOptions.columnDef
            *  @description If specified, cellTemplate to use as the editor for all columns.
            *  
default to 'ui-grid/cellTextEditor' */ @@ -132,6 +135,7 @@ * @ngdoc object * @name enableCellEditOnFocus * @propertyOf ui.grid.edit.api:GridOptions + * @propertyOf ui.grid.class:GridOptions.columnDef * @description If true, then editor is invoked as soon as cell receives focus. Default false *
!! requires cellNav feature !! */ diff --git a/src/js/core/factories/GridColumn.js b/src/js/core/factories/GridColumn.js index 96f3c5af78..fae04bb0a9 100644 --- a/src/js/core/factories/GridColumn.js +++ b/src/js/core/factories/GridColumn.js @@ -11,27 +11,62 @@ angular.module('ui.grid') * @param {ColDef} colDef Column definition. * @param {number} index the current position of the column in the array * @param {Grid} grid reference to the grid -
Required properties -
    -
  • - name - name of field -
  • -
- -
Optional properties -
    -
  • - field - angular expression that evaluates against grid.options.data array element. -
    can be complex - employee.address.city -
    Can also be a function - employee.getFullAddress() -
    see angular docs on binding expressions -
  • -
  • displayName - column name when displayed on screen. defaults to name
  • -
  • sortingAlgorithm - Algorithm to use for sorting this column. Takes 'a' and 'b' parameters like any normal sorting function.
  • -
  • todo: add other optional fields as implementation matures
  • -
- * */ + + /** + * @ngdoc property + * @name ui.grid.class:GridColumn.name + * @propertyOf ui.grid.class:GridColumn + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (mandatory) each column should have a name, although for backward + * compatibility with 2.x name can be omitted if field is present + * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridColumn.displayName + * @propertyOf ui.grid.class:GridColumn + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) name is used if displayName if displayName is not + * provided. If provided then displayName is used in the header. + * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridColumn.field + * @propertyOf ui.grid.class:GridColumn + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) field must be provided if you wish to bind to a + * column in the data source. Should be an angular expression that evaluates against grid.options.data + * array element. Can be a complex expression: employee.address.city, or can be a function: employee.getFullAddress(). + * See the angular docs on binding expressions. + * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridColumn.sortingAlgorithm + * @propertyOf ui.grid.class:GridColumn + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) Algorithm to use for sorting this column. Takes 'a' and 'b' parameters + * like any normal sorting function. + * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridColumn.filter + * @propertyOf ui.grid.class:GridColumn + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) Filter to insert against this column. + * @example + *
{ term: 'text' }
+ * + */ + + function GridColumn(colDef, index, grid) { var self = this; @@ -225,4 +260,4 @@ angular.module('ui.grid') return GridColumn; }]); -})(); \ No newline at end of file +})(); diff --git a/src/js/core/factories/GridOptions.js b/src/js/core/factories/GridOptions.js index bfb422393a..41fa985d03 100644 --- a/src/js/core/factories/GridOptions.js +++ b/src/js/core/factories/GridOptions.js @@ -34,21 +34,33 @@ angular.module('ui.grid') this.data = []; /** - * @ngdoc object - * @name columnDefs + * @ngdoc array + * @name ui.grid.class:GridOptions.columnDefs * @propertyOf ui.grid.class:GridOptions * @description (optional) Array of columnDef objects. Only required property is name. * _field property can be used in place of name for backwards compatibilty with 2.x_ * @example - var columnDefs = [{name:'field1'}, {name:'field2'}]; +
var columnDefs = [{name:'field1'}, {name:'field2'}];
*/ this.columnDefs = []; - + + /** + * @ngdoc object + * @name ui.grid.class:GridOptions.columnDef + * @description (optional) Definition of an individual column, which would typically be + * one of many column definitions within the gridOptions.columnDefs array + * @example + +
{name:'field1', field: 'field1', filter: { term: 'xxx' }}
+ + */ + + /** * @ngdoc array - * @name excludeProperties + * @name ui.grid.class:GridOptions.excludeProperties * @propertyOf ui.grid.class:GridOptions * @description (optional) Array of property names in data to ignore when auto-generating column names. defaults to ['$$hashKey'] * If columnDefs is defined, this will be ignored. @@ -58,7 +70,7 @@ angular.module('ui.grid') /** * @ngdoc boolean - * @name enableRowHashing + * @name ui.grid.class:GridOptions.enableRowHashing * @propertyOf ui.grid.class:GridOptions * @description (optional) True by default. When enabled, this setting allows uiGrid to add * `$$hashKey`-type properties (similar to Angular) to elements in the `data` array. This allows @@ -72,7 +84,7 @@ angular.module('ui.grid') /** * @ngdoc function - * @name rowIdentity + * @name ui.grid.class:GridOptions.rowIdentity * @methodOf ui.grid.class:GridOptions * @description (optional) This function is used to get and, if necessary, set the value uniquely identifying this row. * @@ -84,7 +96,7 @@ angular.module('ui.grid') /** * @ngdoc function - * @name getRowIdentity + * @name ui.grid.class:GridOptions.getRowIdentity * @methodOf ui.grid.class:GridOptions * @description (optional) This function returns the identity value uniquely identifying this row. * @@ -114,13 +126,31 @@ angular.module('ui.grid') this.excessColumns = 4; this.horizontalScrollThreshold = 2; - // Sorting on by default + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.enableSorting + * @propertyOf ui.grid.class:GridOptions + * @description (optional) True by default. When enabled, this setting adds sort + * widgets to the column headers, allowing sorting of the data. + */ this.enableSorting = true; - // Filtering off by default + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.enableFiltering + * @propertyOf ui.grid.class:GridOptions + * @description (optional) False by default. When enabled, this setting adds filter + * boxes to each column header, allowing filtering within the column. + */ this.enableFiltering = false; - // Column menu can be used by default + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.enableColumnMenu + * @propertyOf ui.grid.class:GridOptions + * @description (optional) True by default. When enabled, this setting displays a column + * menu within each column. + */ this.enableColumnMenu = true; // Native scrolling on by default @@ -134,7 +164,7 @@ angular.module('ui.grid') /** * @ngdoc function - * @name rowEquality + * @name ui.grid.class:GridOptions.rowEquality * @methodOf ui.grid.class:GridOptions * @description By default, rows are compared using object equality. This option can be overridden * to compare on any data item property or function @@ -145,10 +175,26 @@ angular.module('ui.grid') return entityA === entityB; }; - // Custom template for header row + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.headerTemplate + * @propertyOf ui.grid.class:GridOptions + * @description (optional) Null by default. When provided, this setting uses a custom header + * template. Can be set to either the name of a template file 'header_template.html', inline html + *
'
I am a Custom Grid Header
'
, or the id + * of a precompiled template '??'. Refer to the custom header tutorial for more information. + */ this.headerTemplate = null; - // Template for rows + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.rowTemplate + * @propertyOf ui.grid.class:GridOptions + * @description (optional) 'ui-grid/ui-grid-row' by default. When provided, this setting uses a + * custom row template. Can be set to either the name of a template file 'row_template.html', inline html + *
'
'
, or the id + * of a precompiled template '??' can be provided. Refer to the custom row template tutorial for more information. + */ this.rowTemplate = 'ui-grid/ui-grid-row'; } From 82e13c275a3aaa1d0b91c9bfbadf42589957500a Mon Sep 17 00:00:00 2001 From: Paul Lambert Date: Sun, 24 Aug 2014 17:54:25 +1200 Subject: [PATCH 3/3] ngDoc updates, focusing on columnDefs A pass through each module looking for settings that are set in columnDefs, and completing ngDoc updates for each. --- src/features/cellnav/js/cellnav.js | 4 +- src/features/edit/js/gridEdit.js | 29 +++--- src/features/pinning/js/pinning.js | 8 +- .../js/ui-grid-column-resizer.js | 8 +- src/features/selection/js/selection.js | 8 +- src/js/core/directives/ui-grid-column-menu.js | 14 +++ src/js/core/factories/Grid.js | 11 +++ src/js/core/factories/GridColumn.js | 98 +++++++++++++++++++ 8 files changed, 162 insertions(+), 18 deletions(-) diff --git a/src/features/cellnav/js/cellnav.js b/src/features/cellnav/js/cellnav.js index 50763d1562..bff448e272 100644 --- a/src/features/cellnav/js/cellnav.js +++ b/src/features/cellnav/js/cellnav.js @@ -278,7 +278,9 @@ * @ngdoc object * @name allowCellFocus * @propertyOf ui.grid.cellNav.api:ColDef - * @description Enable focus on a cell.
Defaults to true + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description Enable focus on a cell. Requires the cell nav feature to be enabled. + *
Defaults to true */ colDef.allowCellFocus = colDef.allowCellFocus === undefined ? true : colDef.allowCellFocus ; diff --git a/src/features/edit/js/gridEdit.js b/src/features/edit/js/gridEdit.js index 1d6a1abdee..678ebe6f3b 100644 --- a/src/features/edit/js/gridEdit.js +++ b/src/features/edit/js/gridEdit.js @@ -102,17 +102,18 @@ * @ngdoc object * @name enableCellEdit * @propertyOf ui.grid.edit.api:GridOptions - * @propertyOf ui.grid.class:GridOptions.columnDef + * @propertyOf ui.grid.class:GridOptions * @description If defined, it will be the default value that colDefs will take if their enableCellEdit is - * not defined. Defaults to undefined. + * not defined. Defaults to undefined. Requires the edit feature to be enabled */ /** * @ngdoc object * @name cellEditableCondition * @propertyOf ui.grid.edit.api:GridOptions - * @propertyOf ui.grid.class:GridOptions.columnDef - * @description If specified, either a value or function to be used by all columns before editing. If falsy, then editing of cell is not allowed + * @propertyOf ui.grid.class:GridOptions + * @description If specified, either a value or function to be used by all columns before editing. If falsy, then editing of cell is not allowed. + * Requires the edit feature to be enabled *
            *  function($scope){
            *    //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed
@@ -126,8 +127,8 @@
            *  @ngdoc object
            *  @name editableCellTemplate
            *  @propertyOf  ui.grid.edit.api:GridOptions
-           *  @propertyOf  ui.grid.class:GridOptions.columnDef
-           *  @description If specified, cellTemplate to use as the editor for all columns.
+           *  @propertyOf  ui.grid.class:GridOptions
+           *  @description If specified, cellTemplate to use as the editor for all columns.  Requires the edit feature to be enabled
            *  
default to 'ui-grid/cellTextEditor' */ @@ -135,8 +136,8 @@ * @ngdoc object * @name enableCellEditOnFocus * @propertyOf ui.grid.edit.api:GridOptions - * @propertyOf ui.grid.class:GridOptions.columnDef - * @description If true, then editor is invoked as soon as cell receives focus. Default false + * @propertyOf ui.grid.class:GridOptions + * @description If true, then editor is invoked as soon as cell receives focus. Default false. Requires the edit feature to be enabled *
!! requires cellNav feature !! */ //enableCellEditOnFocus can only be used if cellnav module is used @@ -166,7 +167,8 @@ * @ngdoc object * @name enableCellEdit * @propertyOf ui.grid.edit.api:ColDef - * @description enable editing on column + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description enable editing on column, requires the edit feature to be enabled. */ colDef.enableCellEdit = colDef.enableCellEdit === undefined ? (gridOptions.enableCellEdit === undefined ? (colDef.type !== 'object'):gridOptions.enableCellEdit) : colDef.enableCellEdit; @@ -175,7 +177,9 @@ * @ngdoc object * @name cellEditableCondition * @propertyOf ui.grid.edit.api:ColDef - * @description If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed. + * Requires the edit feature to be enabled. *
            *  function($scope){
            *    //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed
@@ -189,8 +193,10 @@
            *  @ngdoc object
            *  @name editableCellTemplate
            *  @propertyOf  ui.grid.edit.api:ColDef
+           *  @propertyOf  ui.grid.class:GridOptions.columnDef
            *  @description cell template to used when editing this column. can be Url or text template
            *  
Defaults to gridOptions.editableCellTemplate + * Requires the edit feature to be enabled */ if (colDef.enableCellEdit) { colDef.editableCellTemplate = colDef.editableCellTemplate || gridOptions.editableCellTemplate || @@ -221,8 +227,9 @@ * @ngdoc object * @name enableCellEditOnFocus * @propertyOf ui.grid.edit.api:ColDef + * @propertyOf ui.grid.class:GridOptions.columnDef * @requires ui.grid.cellNav - * @description If true, then editor is invoked as soon as cell receives focus. Default false + * @description If true, then editor is invoked as soon as cell receives focus. Default false. Requires the edit feature to be enabled. *
!! requires cellNav feature !! */ //enableCellEditOnFocus can only be used if cellnav module is used diff --git a/src/features/pinning/js/pinning.js b/src/features/pinning/js/pinning.js index 5f86a4356e..89b39a1959 100644 --- a/src/features/pinning/js/pinning.js +++ b/src/features/pinning/js/pinning.js @@ -58,7 +58,9 @@ * @ngdoc object * @name enableRowSelection * @propertyOf ui.grid.pinning.api:GridOptions - * @description Enable pinning.
Defaults to true + * @propertyOf ui.grid.class:GridOptions + * @description Enable pinning for the entire grid. Requires the pinning feature to be enabled. + *
Defaults to true */ gridOptions.enablePinning = gridOptions.enablePinning !== false; @@ -78,7 +80,9 @@ * @ngdoc object * @name enablePinning * @propertyOf ui.grid.pinning.api:ColDef - * @description Enable pinning.
Defaults to true + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description Enable pinning for the individual column. Requires the pinning feature to be enabled. + *
Defaults to true */ colDef.enablePinning = colDef.enablePinning === undefined ? gridOptions.enablePinning : colDef.enablePinning; diff --git a/src/features/resize-columns/js/ui-grid-column-resizer.js b/src/features/resize-columns/js/ui-grid-column-resizer.js index a42545c633..5cafa0c3da 100644 --- a/src/features/resize-columns/js/ui-grid-column-resizer.js +++ b/src/features/resize-columns/js/ui-grid-column-resizer.js @@ -25,7 +25,9 @@ * @ngdoc object * @name enableColumnResizing * @propertyOf ui.grid.resizeColumns.api:GridOptions - * @description Enable column resizing
Defaults to true + * @propertyOf ui.grid.class:GridOptions + * @description Enable column resizing on the entire grid. Requires the column resizing feature to be enabled. + *
Defaults to true */ gridOptions.enableColumnResizing = gridOptions.enableColumnResizing !== false; @@ -50,7 +52,9 @@ * @ngdoc object * @name enableColumnResizing * @propertyOf ui.grid.resizeColumns.api:ColDef - * @description Enable column resizing
Defaults to GridOptions.enableColumnResizing + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description Enable column resizing on an individual column. Requires column resizing feature to be enabled. + *
Defaults to GridOptions.enableColumnResizing */ //default to true unless gridOptions or colDef is explicitly false colDef.enableColumnResizing = colDef.enableColumnResizing === undefined ? gridOptions.enableColumnResizing : colDef.enableColumnResizing; diff --git a/src/features/selection/js/selection.js b/src/features/selection/js/selection.js index 174c68997c..7ec54ff22d 100644 --- a/src/features/selection/js/selection.js +++ b/src/features/selection/js/selection.js @@ -174,14 +174,18 @@ * @ngdoc object * @name enableRowSelection * @propertyOf ui.grid.selection.api:GridOptions - * @description Enable row selection.
Defaults to true + * @propertyOf ui.grid.class:GridOptions + * @description Enable row selection for entire grid. Requires row selection feature to be enabled. + *
Defaults to true */ gridOptions.enableRowSelection = gridOptions.enableRowSelection !== false; /** * @ngdoc object * @name multiSelect * @propertyOf ui.grid.selection.api:GridOptions - * @description Enable multiple row selection.
Defaults to true + * @propertyOf ui.grid.class:GridOptions + * @description Enable multiple row selection for entire grid. Requires row selection feature to be enabled. + *
Defaults to true */ gridOptions.multiSelect = gridOptions.multiSelect !== false; }, diff --git a/src/js/core/directives/ui-grid-column-menu.js b/src/js/core/directives/ui-grid-column-menu.js index 06b8b61e64..ac35082be9 100644 --- a/src/js/core/directives/ui-grid-column-menu.js +++ b/src/js/core/directives/ui-grid-column-menu.js @@ -33,6 +33,13 @@ angular.module('ui.grid').directive('uiGridColumnMenu', ['$log', '$timeout', '$w // Get the inner menu part. It's what slides up/down var inner = $elm[0].querySelectorAll('.ui-grid-menu-inner'); + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.columnDef.enableSorting + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) True by default. When enabled, this setting adds sort + * widgets to the column header, allowing sorting of the data in the individual column. + */ function sortable() { if (uiGridCtrl.grid.options.enableSorting && typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.enableSorting) { return true; @@ -42,6 +49,13 @@ angular.module('ui.grid').directive('uiGridColumnMenu', ['$log', '$timeout', '$w } } + /** + * @ngdoc boolean + * @name ui.grid.class:GridOptions.columnDef.enableFiltering + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) True by default. When enabled, this setting adds filter + * widgets to the column header, allowing filtering of the data in the individual column. + */ function filterable() { if (uiGridCtrl.grid.options.enableFiltering && typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.enableFiltering) { return true; diff --git a/src/js/core/factories/Grid.js b/src/js/core/factories/Grid.js index fd58da63bc..5a51bce68f 100644 --- a/src/js/core/factories/Grid.js +++ b/src/js/core/factories/Grid.js @@ -1089,6 +1089,17 @@ angular.module('ui.grid') * by this column only * @returns {Promise} A resolved promise that supplies the column. */ + + /** + * @ngdoc constant + * @name ui.grid.class:GridOptions.columnDef.sort + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) Can be used to set the sort direction for the column, values are + * uiGridConstants.ASC or uiGridConstants.DESC + * @example + *
  $scope.gridOptions.columnDefs = [ { field: 'field1', sort: { direction: uiGridConstants.ASC }}]
+   */
+  
   Grid.prototype.sortColumn = function sortColumn(column, directionOrAdd, add) {
     var self = this,
         direction = null;
diff --git a/src/js/core/factories/GridColumn.js b/src/js/core/factories/GridColumn.js
index fae04bb0a9..da88e848a0 100644
--- a/src/js/core/factories/GridColumn.js
+++ b/src/js/core/factories/GridColumn.js
@@ -93,6 +93,104 @@ angular.module('ui.grid')
     }
   };
 
+  
+  
+   /** 
+    * @ngdoc property
+    * @name ui.grid.class:GridOptions.columnDef.width
+    * @propertyOf ui.grid.class:GridOptions.columnDef
+    * @description (optional) sets the column width.  Can be either 
+    * a number or a percentage, or an * for auto.
+    * @example
+    * 
  $scope.gridOptions.columnDefs = [ { field: 'field1', width: 100},
+    *                                          { field: 'field2', width: '20%'},
+    *                                          { field: 'field3', width: '*' }]; 
+ * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridOptions.columnDef.minWidth + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) sets the minimum column width. Should be a number. + * @example + *
  $scope.gridOptions.columnDefs = [ { field: 'field1', minWidth: 100}]; 
+ * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridOptions.columnDef.maxWidth + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) sets the maximum column width. Should be a number. + * @example + *
  $scope.gridOptions.columnDefs = [ { field: 'field1', maxWidth: 100}]; 
+ * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridOptions.columnDef.visible + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) sets whether or not the column is visible + *
Default is true + * @example + *
  $scope.gridOptions.columnDefs = [ { field: 'field1', visible: true},
+    *                                          { field: 'field2', visible: false }]; 
+ * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridOptions.columnDef.sort + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) not clear what this does, but it can be set + * + */ + + /** + * @ngdoc property + * @name ui.grid.class:GridOptions.columnDef.sortingAlgorithm + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) a function that will be used for sorting the column, in standard + * a b format. + * + */ + + /** + * @ngdoc array + * @name ui.grid.class:GridOptions.columnDef.filters + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) unclear what this does or how it's used, but it does something. + * + */ + + /** + * @ngdoc array + * @name ui.grid.class:GridOptions.columnDef.menuItems + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) used to add menu items to a column. Refer to the tutorial on this + * functionality. + * @example + *
  $scope.gridOptions.columnDefs = [ 
+    *   { field: 'field1', menuItems: [
+    *     {
+    *       title: 'Outer Scope Alert',
+    *       icon: 'ui-grid-icon-info-circled',
+    *       action: function($event) {
+    *         this.context.blargh(); // $scope.blargh() would work too, this is just an example
+    *       },
+    *       context: $scope
+    *     },
+    *     {
+    *       title: 'Grid ID',
+    *       action: function() {
+    *         alert('Grid ID: ' + this.grid.id);
+    *       }
+    *     }
+    *   ] }]; 
+ * + */ GridColumn.prototype.updateColumnDef = function(colDef, index) { var self = this;