angular-multi-select
angular-multi-select copied to clipboard
Add functionallity to accept groups without childs.
The following should work:
var u = [
{
name: "<strong>All Browsers</strong>",
msGroup: true
},
{
name: "<strong>Europe</strong>",
msGroup: true,
},
{
msGroup: false
},
{
name: "<strong>Asia & Pacific</strong>",
msGroup: true
},
{
msGroup: false
},
{
name: "<strong>Middle East</strong>",
msGroup: true
},
{
msGroup: false
},
{
msGroup: false
}];
Now only load if I have childs!
var u = [
{
name: "<strong>All Browsers</strong>",
msGroup: true
},
{
name: "<strong>Europe</strong>",
msGroup: true,
},
{
icon: '<img src="https://cdn1.iconfinder.com/data/icons/fatcow/32/opera.png" />',
name: 'Only loads this hierarchy',
maker: 'Only loads this hierarchy',
ticked: false
},
{
msGroup: false
},
{
name: "<strong>Asia & Pacific</strong>",
msGroup: true
},
{
msGroup: false
},
{
name: "<strong>Middle East</strong>",
msGroup: true
},
{
msGroup: false
},
{
msGroup: false
}];
Hi @danicomas ,
Sorry for the late reply.
Actually this is not a bug, I intentionally made it to remove empty groups. But I guess you're right, it should be able to display empty groups. Will update on the next release.
Nice @isteven
Hi @isteven what is the status of this issue? would it be possible to select the group head to select all its members including the header?
For those still interested: The crucial code block in isteven-angular-multiselect/isteven-multi-select.js seems to be
if (
(
!$scope.filteredModel[ $scope.filteredModel.length - 1 ]
||
typeof $scope.filteredModel[ $scope.filteredModel.length - 1 ][ attrs.groupProperty ] !== 'undefined'
)
&&
(
!$scope.filteredModel[ $scope.filteredModel.length - 1 ]
||
$scope.filteredModel[ $scope.filteredModel.length - 1 ][ attrs.groupProperty ] === false
)
) {
$scope.filteredModel.pop();
}
else {
$scope.filteredModel.push( $scope.inputModel[ i ] );
}
You might want to change it so that $scope.filteredModel.push( $scope.inputModel[ i ] );
is either always called or based on an attribute condition.