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

Drop Down List Reset to alphabetically (A-Z) Sorting

Hi all.

I got problem where i need to sort 'Designation' according to seniority and not by alphabetically (A-Z).
I already sort it at stored procedure. (Refer attachment)



But when return view. The designation still sort it according to alphabetically (A-Z). (Refer attachment)







1 Reply

CI Christopher Issac Sunder K Syncfusion Team December 31, 2018 12:42 PM UTC

Hi Farihah, 

Thank you for contacting Syncfusion support. 

We have prepared a sample and validate your reported case. But, we were unable to find out the exact root cause of your reported issue. Based on your shared details, we suspect that the assigned data will be sorted before return to view or DropDownList’s SortOrder may assigned as Ascending.  
So , please ensure the both cases in your end. 
 
Code behind 
<code> 
 
public IActionResult Index() 
        { 
            ViewBag.data = new Vegetables().VegetablesList(); 
 
            //ViewBag.sort = "Ascending"; 
            ViewBag.sort = "None"; 
            return View(); 
        } 
 
</code> 
 
Data: 
<code> 
 
public class Vegetables 
    { 
        public string Vegetable { get; set; } 
        public string Category { get; set; } 
        public string Id { get; set; } 
        public List<Vegetables> VegetablesList() 
        { 
            List<Vegetables> veg = new List<Vegetables>(); 
            veg.Add(new Vegetables { Vegetable = "Yarrow", Category = "Leafy and Salad", Id = "item11" }); 
            veg.Add(new Vegetables { Vegetable = "Wheat grass", Category = "Leafy and Salad", Id = "item10" }); 
            veg.Add(new Vegetables { Vegetable = "Cabbage", Category = "Leafy and Salad", Id = "item1" }); 
            veg.Add(new Vegetables { Vegetable = "Chickpea", Category = "Beans", Id = "item2" }); 
            veg.Add(new Vegetables { Vegetable = "Garlic", Category = "Bulb and Stem", Id = "item3" }); 
            veg.Add(new Vegetables { Vegetable = "Green bean", Category = "Beans", Id = "item4" }); 
            veg.Add(new Vegetables { Vegetable = "Horse gram", Category = "Beans", Id = "item5" }); 
            veg.Add(new Vegetables { Vegetable = "Nopal", Category = "Bulb and Stem", Id = "item6" }); 
            veg.Add(new Vegetables { Vegetable = "Onion", Category = "Bulb and Stem", Id = "item7" }); 
            veg.Add(new Vegetables { Vegetable = "Pumpkins", Category = "Leafy and Salad", Id = "item8" }); 
            veg.Add(new Vegetables { Vegetable = "Spinach", Category = "Leafy and Salad", Id = "item9" }); 
             
             
            return veg; 
        } 
    } 
 
</code> 
 
View: 
<code> 
<ejs-dropdownlist id="games" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px" sortOrder="@ViewBag.sort" > 
    <e-dropdownlist-fields text="Vegetable" value="Id"></e-dropdownlist-fields> 
</ejs-dropdownlist> 
</code> 


Please let us know if you require any further assistance. 

Thanks, 
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon