We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom order for dropdown inside Grid

Thread ID:





147129 Sep 2,2019 04:28 PM UTC Sep 4,2019 06:13 PM UTC ASP.NET Core - EJ 2 1
Tags: Dropdown List
Javier A Aguilera
Asked On September 2, 2019 04:28 PM UTC

Good morning gentlemen,

I'm trying to put a dropdownlist inside a Grid (which is easy to do), the thing is that in this dropdown I need to put the elements in a specific order different than the alphabetical, can you help me please with this one?

The column for the dropdown is "Parentezco", and "Orden" is a field of the table that I'm trying to use to order the ViewBag content

In advance, thanks!

/////////MY GRID IN THE VIEW/////////////////////

<ejs-grid id="DetalleFormatoAltaGmmVidaApGrid" dataBound="dataBound" locale="es-MX" query="new ej.data.Query().addParams('FormatoID', '@Model.FormatoID')" toolbar="@(new List<string>() { "Cancel", "Update", "Add", "Delete" })">
        <e-data-manager id="dataManager" adaptor="UrlAdaptor" url="/Sistema/Formatos/DetalleFormatoAltaGmmVidaApGrid_Read/" crudUrl="/Sistema/Formatos/BeneficiariosAccidentesPersonalesGrupalGrid_CRUD" requestType="Post"></e-data-manager>
        <e-grid-editSettings allowDeleting="true" allowEditing="true" allowAdding="true" mode="Normal" showDeleteConfirmDialog="true"></e-grid-editSettings>
            <e-grid-column field="DetalleID" isPrimaryKey="true" isIdentity="true" visible="false"></e-grid-column>
            <e-grid-column field="Parentezco" headerText="Parentezco" foreignKeyField="TipoParentezco" foreignKeyValue="Descripcion" dataSource="@ViewBag.TiposParentezco"></e-grid-column>


///////////////////CONTROLLER SIDE///////////////////

ViewBag.TiposParentezco = _context.TiposParentezco.OrderBy(p => p.Orden).ToList();

Ashokkumar Balasubramanian [Syncfusion]
Replied On September 3, 2019 02:16 PM UTC

Hi Javier, 
Greetings from Syncfusion support. 
For this scenario, you can use our sortOrder property of DropdownList component to achieve it. Could you please check the below code block and sample? 
<ejs-grid id="Grid" dataSource="@ViewBag.datasource" height="315" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column> 
        <e-grid-column field="CustomerID" headerText="Customer ID" edit="@(new {create = "create", read = "read", destroy = "destroy", write = "write"})" type="string" width="120"></e-grid-column> 
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" editType="numericedit" width="120"></e-grid-column> 
        <e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column> 
    var elem; 
    var drpObj; 
    function create(args) { 
        elem = document.createElement('input'); 
        return elem; 
    function write(args) { 
        var grid = document.getElementById('Grid')["ej2_instances"][0]; 
        var data = grid.dataSource; 
        drpObj = new ej.dropdowns.DropDownList({ 
            value: args.rowData[args.column.field], 
            dataSource: data, 
            fields: { text: 'CustomerID', value: 'CustomerID' }, 
            sortOrder: 'None' 
    function destroy() { 
    function read(args) { 
        return drpObj.value; 
Please check the sample and get back to us, if you require any further assistance on this. 
Ashokkumar B. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon