How to display div based on selected multiselect
I am trying to show/hide elements based on multiselect dropdown, but my code doesn't seem to work. For example, one of the data for nameList is Name, and when Name is selected, I would like to display a div with another drop-down menu. I am using Angular and Typescript. Below are my codes for your reference:
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="selectedname === 'Name'">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
angular typescript kendo-ui
add a comment |
I am trying to show/hide elements based on multiselect dropdown, but my code doesn't seem to work. For example, one of the data for nameList is Name, and when Name is selected, I would like to display a div with another drop-down menu. I am using Angular and Typescript. Below are my codes for your reference:
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="selectedname === 'Name'">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
angular typescript kendo-ui
Hey, can you put theYou selected {{selectedname}}
line outside the if, and just below the firstkendo-multiselect
and show me the output? You are treating like theselectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.
– user8401765
Nov 21 '18 at 5:33
add a comment |
I am trying to show/hide elements based on multiselect dropdown, but my code doesn't seem to work. For example, one of the data for nameList is Name, and when Name is selected, I would like to display a div with another drop-down menu. I am using Angular and Typescript. Below are my codes for your reference:
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="selectedname === 'Name'">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
angular typescript kendo-ui
I am trying to show/hide elements based on multiselect dropdown, but my code doesn't seem to work. For example, one of the data for nameList is Name, and when Name is selected, I would like to display a div with another drop-down menu. I am using Angular and Typescript. Below are my codes for your reference:
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="selectedname === 'Name'">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
angular typescript kendo-ui
angular typescript kendo-ui
asked Nov 21 '18 at 5:13
Adibah Hanun Abu SemanAdibah Hanun Abu Seman
33
33
Hey, can you put theYou selected {{selectedname}}
line outside the if, and just below the firstkendo-multiselect
and show me the output? You are treating like theselectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.
– user8401765
Nov 21 '18 at 5:33
add a comment |
Hey, can you put theYou selected {{selectedname}}
line outside the if, and just below the firstkendo-multiselect
and show me the output? You are treating like theselectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.
– user8401765
Nov 21 '18 at 5:33
Hey, can you put the
You selected {{selectedname}}
line outside the if, and just below the first kendo-multiselect
and show me the output? You are treating like the selectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.– user8401765
Nov 21 '18 at 5:33
Hey, can you put the
You selected {{selectedname}}
line outside the if, and just below the first kendo-multiselect
and show me the output? You are treating like the selectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.– user8401765
Nov 21 '18 at 5:33
add a comment |
2 Answers
2
active
oldest
votes
On change event of "kendo-mutliselecet" push selectedname item to "anotherList" then set kendo-dropdownlist [(ngModel)] to this selectedname.
<div *ngIf="selectedname.indexOf('Name')>=0">
I think it will be solution. Not tested.
add a comment |
Basically here selectedname
returns an array, so you need to check whether an item exists in an array or not. So you can use the below code to check -
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="isShown('Name')">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
isShown(flag) {
console.log(this.selectedname.indexOf(flag));
if (this.selectedname.indexOf(flag) !== -1) {
return true;
} else {
return false;
}
}
Working example
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405622%2fhow-to-display-div-based-on-selected-multiselect%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
On change event of "kendo-mutliselecet" push selectedname item to "anotherList" then set kendo-dropdownlist [(ngModel)] to this selectedname.
<div *ngIf="selectedname.indexOf('Name')>=0">
I think it will be solution. Not tested.
add a comment |
On change event of "kendo-mutliselecet" push selectedname item to "anotherList" then set kendo-dropdownlist [(ngModel)] to this selectedname.
<div *ngIf="selectedname.indexOf('Name')>=0">
I think it will be solution. Not tested.
add a comment |
On change event of "kendo-mutliselecet" push selectedname item to "anotherList" then set kendo-dropdownlist [(ngModel)] to this selectedname.
<div *ngIf="selectedname.indexOf('Name')>=0">
I think it will be solution. Not tested.
On change event of "kendo-mutliselecet" push selectedname item to "anotherList" then set kendo-dropdownlist [(ngModel)] to this selectedname.
<div *ngIf="selectedname.indexOf('Name')>=0">
I think it will be solution. Not tested.
answered Nov 21 '18 at 5:34
Serkan KONAKCISerkan KONAKCI
15914
15914
add a comment |
add a comment |
Basically here selectedname
returns an array, so you need to check whether an item exists in an array or not. So you can use the below code to check -
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="isShown('Name')">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
isShown(flag) {
console.log(this.selectedname.indexOf(flag));
if (this.selectedname.indexOf(flag) !== -1) {
return true;
} else {
return false;
}
}
Working example
add a comment |
Basically here selectedname
returns an array, so you need to check whether an item exists in an array or not. So you can use the below code to check -
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="isShown('Name')">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
isShown(flag) {
console.log(this.selectedname.indexOf(flag));
if (this.selectedname.indexOf(flag) !== -1) {
return true;
} else {
return false;
}
}
Working example
add a comment |
Basically here selectedname
returns an array, so you need to check whether an item exists in an array or not. So you can use the below code to check -
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="isShown('Name')">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
isShown(flag) {
console.log(this.selectedname.indexOf(flag));
if (this.selectedname.indexOf(flag) !== -1) {
return true;
} else {
return false;
}
}
Working example
Basically here selectedname
returns an array, so you need to check whether an item exists in an array or not. So you can use the below code to check -
<kendo-multiselect [data]="nameList" [(ngModel)]="selectedname "></kendo-multiselect>
<div *ngIf="isShown('Name')">
<div class="col-4">
You selected {{selectedname}}
</div>
<div class="col-2">Name:</div>
<div class="col-6">
<kendo-dropdownlist style="width: 100%" [data]="anotherList" [valuePrimitive]="true"></kendo-dropdownlist>
</div>
</div>
isShown(flag) {
console.log(this.selectedname.indexOf(flag));
if (this.selectedname.indexOf(flag) !== -1) {
return true;
} else {
return false;
}
}
Working example
answered Nov 21 '18 at 5:33
Pardeep JainPardeep Jain
41.1k17103145
41.1k17103145
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405622%2fhow-to-display-div-based-on-selected-multiselect%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hey, can you put the
You selected {{selectedname}}
line outside the if, and just below the firstkendo-multiselect
and show me the output? You are treating like theselectedname
will be a string, but I suspect its an Object since it doesnt have to store only one name.– user8401765
Nov 21 '18 at 5:33