Disabled Items in Mention Control

17 Sep 20244 minutes to read

The Mention provides options for individual items to be either in an enabled or disabled state for specific scenarios. The category of each list item can be mapped through the disabled field in the data table. Once an item is disabled, it cannot be selected as a value for the component. To configure the disabled item columns, use the fields.disabled property.

In the following sample, State are grouped according on its category using disabled field.

@{
    char nameMentionChar = '@';
    List<DisableStatusData> status = new DisableStatusData().StatusDataList();
}

<div id="mentionElement" placeholder = "Type @@ and tag sport"></div>
<ejs-mention id="comments" dataSource="@status" mentionChar="@nameMentionChar" target="#mentionElement">
    <e-mention-fields value="Status" disabled="State" ></e-mention-fields>
</ejs-mention>


<style>

    div#mentionElement[placeholder]:empty:before {
        content: attr(placeholder);
    }

    #mentionElement{
        min-height: 100px; 
        border: 1px solid #D7D7D7;
        border-radius: 4px; 
        padding: 8px; 
        font-size: 14px; 
        width: 600px;
    }
    
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Models
{
    public class DisableStatusData
    {
        public string Status { get; set; }
        public bool State { get; set; }
        public List<DisableStatusData> StatusDataList()
        {
            List<DisableStatusData> status = new List<DisableStatusData>();
            status.Add(new DisableStatusData() { Status = "Open", State= false });
            status.Add(new DisableStatusData() { Status = "Waiting for Customer", State= false });
            status.Add(new DisableStatusData() { Status = "On Hold", State= true });
            status.Add(new DisableStatusData() { Status = "Follow-up", State= false });
            status.Add(new DisableStatusData() { Status = "Closed", State= true });
            status.Add(new DisableStatusData() { Status = "Solved", State= false });
            status.Add(new DisableStatusData() { Status = "Feature Request", State= false });

            return status;
        }
    }
}

Disable Item Method

The disableItem method can be used to handle dynamic changing in disable state of a specific item. Only one item can be disabled in this method. To disable multiple items, this method can be iterated with the items list or array. The disabled field state will to be updated in the dataSource, when the item is disabled using this method.

Parameter Type Description
itemHTMLLIElement HTMLLIElement It accepts the HTML Li element of the item to be removed.
itemValue string | number | boolean | object It accepts the string, number, boolean and object type value of the item to be removed.
itemIndex number It accepts the index of the item to be removed.