<div class="btn-group"
is-open="gridMenuIsOpen" ng-if="menuLabel" dropdown>
- <button type="button" class="btn btn-default dropdown-toggle eg-grid-menui-item">
+ <button type="button" class="btn btn-default dropdown-toggle eg-grid-menu-item">
{{menuLabel}}<span class="caret"></span>
</button>
<ul class="dropdown-menu">
ng-click="item.handler()">{{item.label}}</a>
</li>
</ul>
- <button ng-if="!item.hidden()"
- class="btn btn-default eg-grid-menui-item"
+ <button ng-if="!item.checkbox && !item.hidden()"
+ class="btn btn-default eg-grid-menu-item"
ng-disabled="item.disabled()"
ng-repeat="item in menuItems | filter : { standalone : 'true' }"
ng-click="item.handler()">{{item.label}}</button>
<!-- if no menu label is present, present menu-items as a
horizontal row of buttons -->
<div class="btn-group" ng-if="!menuLabel">
- <button ng-if="!item.hidden()"
+ <button ng-if="!item.checkbox && !item.hidden()"
class="btn btn-default eg-grid-menu-item"
- ng-disabled="item.disabled()"
ng-repeat="item in menuItems"
+ ng-disabled="item.disabled()"
ng-click="item.handler(item, item.handlerData)">
- {{item.label}}
+ {{item.label}}
+ </button>
+ <button ng-if="item.checkbox"
+ class="btn btn-default eg-grid-menu-item"
+ ng-repeat="item in menuItems">
+ {{item.label}}
+ <input style="padding-left: 5px"
+ type="checkbox"
+ ng-disabled="item.disabled()"
+ ng-model="item.checked"
+ ng-checked="item.checked"
+ ng-change="item.handler(item)"/>
</button>
</div>
grid.controls = controls;
}
+ // If a menu item provides its own HTML template, translate it,
+ // using the menu item for the template scope.
+ // note: $sce is required to avoid security restrictions and
+ // is OK here, since the template comes directly from a
+ // local HTML template (not user input).
+ $scope.translateMenuItemTemplate = function(item) {
+ var html = egCore.strings.$replace(item.template, {item : item});
+ return $sce.trustAsHtml(html);
+ }
+
// add a new (global) grid menu item
grid.addMenuItem = function(item) {
$scope.menuItems.push(item);
require : '^egGrid',
scope : {
label : '@',
+ checkbox : '@',
+ checked : '=',
standalone : '=',
handler : '=', // onclick handler function
divider : '=', // if true, show a divider only
},
link : function(scope, element, attrs, egGridCtrl) {
egGridCtrl.addMenuItem({
+ checkbox : scope.checkbox,
+ checked : scope.checked ? true : false,
label : scope.label,
standalone : scope.standalone ? true : false,
handler : scope.handler,