Drop Down List Field in dataGrid not displaying data (Request Failed)

hello 


the dropdown list in the field gives me request failed  all other columns load fine 
but the dropdown field not 

<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" allowPaging="true" locale="en-US" allowGrouping="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">

    <e-data-manager url="/StoreFixes/UrlDataSource" insertUrl="/StoreFixes/Insert" updateUrl="/StoreFixes/Update" removeUrl="/StoreFixes/Delete" adaptor="UrlAdaptor"></e-data-manager>


    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog"></e-grid-editSettings>


    <e-grid-columns>

        <e-grid-column field="Nom" headerText="Nom" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="Prenom" headerText="Prenom" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="Id" headerText="Id" isPrimaryKey="true" isIdentity="true" visible="false" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="Nif" headerText="Nif" textAlign="Right" width="120"></e-grid-column>



        <e-grid-column field="NifAutorité" headerText="NifAutorité" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="QualitéSignNavigation" editType='dropdownedit' headerText="QualitéSign" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="Fax" headerText="Fax" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="NCompte" headerText="NCompte" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="NAffiliation" headerText="NAffiliation" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column field="Banque" headerText="Banque" textAlign="Right" width="120"></e-grid-column>

        <e-grid-column editType='dropdownedit' field="Id" headerText="QualitéSign" dataSource="@ViewBag.QualitéSign" width="110"> </e-grid-column>

    </e-grid-columns>

</ejs-grid>



in the controller 

 public async Task<IActionResult> Index()

        {

            ViewData["QualitéSign"] = new SelectList(_context.QualitéSigns, "Id", "Id");

            ViewData["TypeEnt"] = new SelectList(_context.TypeEnts, "Id", "Id");


            var pGIsmartContext = _context.Storefixes.Include(e => e.QualitéSignNavigation).Include(e => e.TypeEntNavigation);

            ViewBag.DataSource = await _context.Storefixes.Include(e => e.QualitéSignNavigation).Include(e => e.TypeEntNavigation).ToListAsync();


            return View(await pGIsmartContext.ToListAsync());

        }



        public ActionResult Delete([FromBody] CRUDModel<Storefix> value)

        {

            ViewData["QualitéSign"] = new SelectList(_context.QualitéSigns, "Id", "Id");

            ViewData["TypeEnt"] = new SelectList(_context.TypeEnts, "Id", "Id");


            //do stuff

            Storefix Storefix = _context.Storefixes.Where(c => c.Id == int.Parse(value.Key.ToString())).FirstOrDefault();



            _context.Storefixes.Remove(Storefix);

            _context.SaveChanges();

            return Json(Storefix);

        }

        public ActionResult Insert([FromBody] CRUDModel<Storefix> value)

        {


            ViewData["QualitéSign"] = new SelectList(_context.QualitéSigns, "Id", "Id");

            ViewData["TypeEnt"] = new SelectList(_context.TypeEnts, "Id", "Id");



            ViewBag.Data = new SelectList(_context.QualitéSigns, "Id", "Id").ToList();


            //do stuff

            _context.Storefixes.Add(value.Value);

            _context.SaveChanges();

            return Json(value.Value);

        }

        public ActionResult UrlDatasource([FromBody] DataManagerRequest dm)

        {

            ViewData["QualitéSign"] = new SelectList(_context.QualitéSigns, "Id", "Id");

            ViewData["TypeEnt"] = new SelectList(_context.TypeEnts, "Id", "Id");


            IEnumerable DataSource = _context.Storefixes.Include(e => e.QualitéSignNavigation).Include(e => e.TypeEntNavigation).ToList();


            DataOperations operation = new DataOperations();

            if (dm.Search != null && dm.Search.Count > 0)

            {

                DataSource = operation.PerformSearching(DataSource, dm.Search); //Search

            }

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting

            {

                DataSource = operation.PerformSorting(DataSource, dm.Sorted);

            }

            int count = DataSource.Cast<Storefix>().Count();

            if (dm.Skip != 0)//Paging

            {

                DataSource = operation.PerformSkip(DataSource, dm.Skip);

            }

            if (dm.Take != 0)

            {

                DataSource = operation.PerformTake(DataSource, dm.Take);

            }


            return Json(new { result = DataSource, count = count });

        }




1 Reply

RS Rajapandiyan Settu Syncfusion Team February 28, 2022 12:22 PM UTC

Hi Gat, 
 
Thanks for contacting Syncfusion support. 
 
By analyzing your code example, we found that you did not return the data in expected format from the server to the Dropdown. This is the cause of reported behavior. 
 
In some of the cases, Grid expects the array of data from server instead of result and count object. Which is handled through the RequiresCounts property. If the RequiresCounts property is false, we need to return the array of data from the server. 
 
You can resolve the reported problem by using following highlighted code. 
 
 
 
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
{ 
    IEnumerable DataSource = OrdersDetails.GetAllRecords().ToList(); 
     // perform the actions here 
    ----    
    // return the data based on RequiresCount 
    return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
} 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Rajapandiyan S 


Loader.
Up arrow icon