Get the total count of data when remote data bind with DropDownList

12 Apr 20222 minutes to read

Before control rendering, you can get the total items count by using actionComplete event with its result arguments. After rendering this control, you can get the total items count by using getItems method.

<ejs-button id="btn" content="Get Items"></ejs-button>
<div class="control-wrapper">
    <div id="default" style='padding-top:75px;'>
        <ejs-dropdownlist id="customers" query="new'Customers').select(['ContactName', 'CustomerID']).take(6)" placeholder="Select a customer" popupHeight="200px">
            <e-dropdownlist-fields text="ContactName" value="CustomerID"></e-dropdownlist-fields>
            <e-data-manager url="" adaptor="ODataV4Adaptor" crossDomain="true"></e-data-manager>
<p id='event'> </p>
    document.getElementById('btn').onclick = () => {
        var element = document.createElement('p');
        document.getElementById("event").innerHTML = "";
        var Obj = document.getElementById("customers").ej2_instances[0];
        element.innerText = "Total items count: " + Obj.getItems().length;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
    public class DropDownListController : Controller
        public ActionResult totalcount()
            return View();