- Home
- Forum
- ASP.NET Core - EJ 2
- How to check chip selected or not
How to check chip selected or not
I am displaying the chip list using the below code and execute the filter event.
<ejs-chiplist id="chip-filterTags" selection="Single" click="FilterClasses" cssClass="e-primary">
<e-chips>
@foreach (var product in (List<FilterTagInfo>)ViewBag.FilterTags)
{
<e-chip text="@product.Name" value="@product.FilterTagID" enabled="true"></e-chip>
}
</e-chips>
</ejs-chiplist>
And here is my filterClasses event.
function FilterClasses(e) {
var FilterTagInfo = {};
FilterTagInfo.FilterTagID = e.data.value;
FilterTagInfo.Name = e.text;
console.log(FilterTagInfo.FilterTagID);
console.log( FilterTagInfo.Name );
}
Now here comes my query. FOR EXAMPLE, CHECK THE BELOW LIST.
LIST:- ALL MATHS SCIENCE GEOGRAPHY ENVIRONMENT
1) When FIRST TIME PAGE RUN AND CLICK ON CHIP, let's say MATHS in console.log, it displays MATHS AND ID OF THE MATHS 5.
2) Now when I, UN-CHECK MATHS, in console.log it again shows me MATHS AND ID OF THE MATHS 5. but I want to fire a condition if the user dis-select the same chip and ALSO NO CHIP is selected then PASS the ID value as 100 and CHIP TEXT as ALL.
We checked your query and suspect that you need to check whether the chip item is selected or unselected in ChipList. You can achieve your requirement using the selected arguments of click event as demonstrated in the below code snippet.
|
<ejs-chiplist id="chip-filterTags" click="FilterClasses" selection="Single">
. . .
</ejs-chiplist>
<script>
function FilterClasses(args) {
if (args.selected == true) { //to check whether the chip is selected or not
var FilterTagInfo = {};
FilterTagInfo.FilterTagID = args.data.value;
FilterTagInfo.Name = args.text;
}
else {
var FilterTagInfo = {};
FilterTagInfo.FilterTagID = 100;
FilterTagInfo.Name = null;
}
}
</script> |
Please get back to us if you need further assistance.
Regards,
Hello
Shalini,
Thank you very much for the code. I am trying to use the same logic but just forgot the specify the condition related to ==true.
Thanks
Hello
Keerthana,
That is what the reason I generally prefer my Client to USE the synfusion, because of the forum gives me a perfect reply with the example.
Again thank you very much.
Thanks
- 5 Replies
- 3 Participants
- Marked answer
-
HP Harshida Parmar
- Sep 8, 2021 09:16 AM UTC
- Sep 9, 2021 02:18 PM UTC