- Home
- Forum
- ASP.NET Core - EJ 2
- Multi select with from enum
Multi select with from enum
- Jun 22, 2020 08:49 AM UTC
- Jun 23, 2020 10:48 AM UTC
i need help with enum multi select i want to implement.
here is my enum model
using System.ComponentModel.DataAnnotations;
namespace NotificationService.Model
{
public enum NotificationType
{
[Display(Name = "Sms")]
SMS = 0,
[Display(Name = "Email")]
EMAIL = 1,
[Display(Name = "Push")]
PUSH = 2
}
}
My model where i wan to save my list of notification type namespace Dashboard.Models
{
public class NotificationConfig
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }
[Required]
public List<NotificationType> NotificationType { get; set; }
}
}
view i started putting my multi select component, but i don't know how to make this work, my goal is to select multiple notification type, can you help me do this Below line does not work becouse i did not put any datasource.<ejs-multiselect id="box" dataSource="" placeholder="Select Notification Types" mode="Box"></ejs-multiselect>
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
BC
Berly Christopher
Syncfusion Team
June 23, 2020 10:48 AM UTC
Hi Nur,
Greetings from Syncfusion support.
We have checked the reported requirement and prepared the sample with ENUM date type and attached below.
Sample Link: https://www.syncfusion.com/downloads/support/forum/155402/ze/MultiSelect_Enum-825155045
|
[index.cshtml]
@model Dropdownlistcore.Controllers.Person
<ejs-multiselect id="dropdown" ejs-for="@Model.Gender" dataSource="Html.GetEnumSelectList<NotificationType>()">
<e-multiselect-fields value="Value" text="Text"></e-multiselect-fields>
</ejs-multiselect> |
|
[HomeController.cs]
namespace Dropdownlistcore.Controllers
{
public class Person
{
[Required]
[Display(Name = "Name")]
public string Name { get; set; }
[Display(Name = "Gender")]
public string Gender { get; set; }
[Display(Name = "NotificationType")]
public NotificationType NotificationText { get; set; }
}
public enum NotificationType
{
[Display(Name = "Sms")]
SMS = 0,
[Display(Name = "Email")]
EMAIL = 1,
[Display(Name = "Push")]
PUSH = 2
}
public class HomeController : Controller
{
public IActionResult Index()
{
Person model = new Person();
model.NotificationText = NotificationType.SMS;
ViewBag.gender = NotificationType.SMS;
return View(model);
}
}
} |
Still facing issues, please share the issue reproducing sample that will help us to check and proceed further at our end.
Regards,
Berly B.C
Marked as answer
SIGN IN To post a reply.