Created
September 6, 2017 14:50
-
-
Save rbaty-barr/846ebae4a438998c873a8f62379707bd to your computer and use it in GitHub Desktop.
This is a sample of a custom pre-vaule editor that is a checkbox property for the grid
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
[ | |
{ | |
"label": "Show by state", | |
"description": "Show this row for the following states.", | |
"key": "state", | |
"view": "/App_Plugins/StatePicker/state-picker-list.html", | |
"applyTo": "row", | |
"defaultConfig": { | |
"selectMultiple": true, | |
"displaySelectInversed": true, | |
"items": [ | |
{ | |
"text": "Arizona", | |
"value": "arizona", | |
"selected": false | |
}, | |
{ | |
"text": "California", | |
"value": "california", | |
"selected": false | |
}, | |
{ | |
"text": "Colorado", | |
"value": "colorado", | |
"selected": false | |
}, | |
{ | |
"text": "New Mexico West Texas", | |
"value": "new-mexico-west-texas", | |
"selected": false | |
} | |
] | |
} | |
} | |
] |
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
{ | |
"gridEditors": [ | |
{ | |
"name": "States", | |
"alias": "states", | |
"view": "/app_plugins/StatePicker/state-picker-list.html", | |
"icon": "icon-code", | |
"config": { | |
"items": [ | |
{ | |
"text": "Arizona", | |
"value": "arizona", | |
"selected": false | |
}, | |
{ | |
"text": "California", | |
"value": "california", | |
"selected": false | |
}, | |
{ | |
"text": "Colorado", | |
"value": "colorado", | |
"selected": false | |
}, | |
{ | |
"text": "New Mexico West Texas", | |
"value": "new-mexico-west-texas", | |
"selected": false | |
} | |
] | |
} | |
} | |
], | |
javascript:[ | |
"/app_plugins/StatePicker/state-picker.controller.js" | |
] | |
} |
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
<div ng-controller="state-picker.controller"> | |
<div ng-repeat="item in items" class="checkbox" ng-class="{'displaySelectInversed': model.defaultConfig.displaySelectInversed}"> | |
<label> | |
<input type="checkbox" value="{{item.value}}" ng-model="item.selected" ng-click="select(item)"> | |
{{item.text}} | |
</label> | |
</div> | |
</div> |
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
angular.module('umbraco').controller('state-picker.controller', function ($scope, $http, $routeParams, assetsService, contentResource, notificationsService) { | |
assetsService.loadCss('/App_Plugins/StatePicker/styles.css'); | |
$scope.items = $scope.model.defaultConfig ? $scope.model.defaultConfig.items : $scope.model.config.items; | |
if ($scope.model.value) { | |
var values = $scope.model.value.split(' '); | |
for (var y = 0; y < values.length; y++) { | |
for (var i = 0; i < $scope.items.length; i++) { | |
if ($scope.items[i].value == values[y]) { | |
$scope.items[i].selected = true; | |
} | |
} | |
} | |
} | |
$scope.select = function (item) { | |
$scope.setValue(); | |
}; | |
$scope.setValue = function () { | |
$scope.model.value = ''; | |
for (var i = 0; i < $scope.items.length; i++) { | |
if ($scope.items[i].selected) { | |
$scope.model.value += $scope.items[i].value + ' '; | |
} | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment