-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
68 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
document.addEventListener('RockGridReady', function(e) { | ||
RockGrid.coldefs.date = function(colDef, params) { | ||
var params = params || {}; | ||
colDef.cellRenderer = RockGrid.renderers.date; | ||
colDef.cellRendererParams = { | ||
format: params.format | ||
RockGrid.colDefs.date = function(col) { | ||
if(!col) return; | ||
|
||
// set coldefs | ||
col.valueGetter = function(params) { | ||
if(typeof params.data == 'undefined') return; | ||
var val = params.data[col.field]; | ||
var date = moment(val); | ||
|
||
if(!date.isValid()) return ''; | ||
return date.format('YYYY-MM-DD'); | ||
} | ||
colDef.filter = 'agDateColumnFilter'; | ||
}; | ||
|
||
return RockGrid.colDefs.fixedWidth(col, 100); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
document.addEventListener('RockGridReady', function(e) { | ||
RockGrid.colDefs.fixedWidth = function(col, width) { | ||
col.width = width || 100; | ||
col.suppressSizeToFit = true; | ||
return col; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,24 @@ | ||
# Attention: The concept of "colDefPlugins" is deprecated | ||
# Library of useful column-definitions | ||
|
||
I switched to a function-based concept and will update the docs as soon as possible. | ||
ColDefs can be used to change columns to repeating needs. For example you can | ||
use a coldef plugin to make the ID column not show the plain id as number but | ||
to show clickable icons: | ||
|
||
# Column Definitions Plugins | ||
|
||
For some column types like dates or currencies you need to define multiple aspects. For numbers for example you need to make sure the value is a number (not a string) and you need to set the proper filter for that column. All those things can be placed in a coldef-plugin and then be reused across your grids or projects. | ||
|
||
## Usage | ||
```js | ||
col = grid.getColDef('id'); | ||
col = RockGrid.colDefs.rowactions(col); | ||
``` | ||
|
||
coldef-plugins are placed in the `/site/[assets|modules]/RockGrid/coldefs` folder. To add a new coldef-type see the existing files like `date.js` or `number.js`. | ||
![rowactions](https://i.imgur.com/Ml0ipqq.png) | ||
|
||
To use those plugins add them like so: | ||
Some colDefs can also be defined with an extra options object: | ||
|
||
```js | ||
document.addEventListener('RockGridItemBeforeInit', function(e) { | ||
if(e.target.id != 'RockGridItem_yourgridid') return; | ||
var grid = RockGrid.getGrid(e.target.id); | ||
|
||
grid.addColDefPlugins({ | ||
answercount: 'number', | ||
}); | ||
col = grid.getColDef('id'); | ||
col = RockGrid.colDefs.rowactions(col, { | ||
strShow: 'Open this page in a PW-Panel', | ||
noTrash: true, | ||
}); | ||
``` | ||
|
||
This will use the `number` coldef-plugin for the column `answercount` making it text-align: right and using the number-filter. If the colStats plugin is enabled this will also make it show the sum() of the column. | ||
|
||
## Advanced | ||
|
||
```js | ||
answers: {name: 'number', valueGetter: function(params) { | ||
var val = params.data[answercol.field]; | ||
if(!val) return 0; | ||
return val.split(',').length; | ||
}}, | ||
``` | ||
![custom-options](https://i.imgur.com/xMjK1nG.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters