Group items in Popup

7 Jun 20243 minutes to read

Grouped items are possible in SplitButton by templating entire popup with ListView. Check ListView grouping and create such items. Create ListView with id listview and provide element of the ListView as target of SplitButton to render it in popup area.

In this following example, ListView is created and its element is set as target for SplitButton.

@using Syncfusion.EJ2.Lists;

@Html.EJS().ListView("listview").Enable(true).DataSource((IEnumerable<object>)ViewBag.items).Fields(new ListViewFieldSettings { GroupBy = "category" }).SortOrder(SortOrder.Descending).Render()
@Html.EJS().SplitButton("element").Content("Clipboard").Target("#listview").Render()

<style>
    .e-split-btn-wrapper{
        margin: 20px 20px 5px 5px;
    }
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.SplitButtons;

namespace EJ2CoreSampleBrowser.Controllers.Button
{
    public partial class ButtonController : Controller
    {
        public ActionResult SplitButton()
        {
            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Cut",
                category = "Basic"
            });
            items.Add(new
            {
                text = "Copy",
                category = "Basic"
            });
            items.Add(new
            {
                text = "Paste",
                category = "Basic"
            });
            items.Add(new
            {
                text = "Paste as Formula",
                category = "Advanced"
            });
            items.Add(new
            {
                text = "Paste as Hyperlink",
                category = "Advanced"
            });
            ViewBag.items = items;
            return View();
        }
    }
}