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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DropDownList in the ToolBar of Grid

Thread ID:





125675 Sep 1,2016 06:22 PM UTC Sep 2,2016 08:51 AM UTC ASP.NET MVC 1
Tags: Grid
Marlon Luft Salvador
Asked On September 1, 2016 06:22 PM UTC

Hi, i'm doing a grid in MVC and i need to create a dropdownlist with categories to filter the grid data.

Could you provide me an example?

        .Datasource(x => x.Json((IEnumerable<MyModel>)Model.Outros)
                .UpdateURL(Url.Action("OutrosUpdate", "MyController"))
                .InsertURL(Url.Action("OutrosInsert", "MyController"))
                .RemoveURL(Url.Action("OutrosDelete", "MyController"))
        .EditSettings(edit =>
        .ToolbarSettings(tool =>
            tool.ShowToolbar().ToolbarItems(x =>
                .PageSettings(Page => { Page.PageSize(5); })
        .Columns(col =>

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 2, 2016 08:51 AM UTC

Hi Marlon, 

We suspect that you would like to filter the Grid data by selecting values in the dropdown which has been rendered in the toolbar of the Grid.  

You can place the DropDownList control in Grid toolbar using “CustomToolbarItem” property of Grid ToolbarSettings. In the change event of the DropDownlist, you can filter the Grid using the filterColumn Grid method. To clear the filtered records, you can use the clearFiltering method of the Grid. We have rendered the ejDropDownlist control in the DataBound event of the Grid. Refer to the following code example. 

<script id="Drop" type="text/x-jsrender"> 
    <input id="dropDown" /> 
        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource) 
             . . . 
        .ToolbarSettings(toolbar => 
              . . .  
            new List<object>() {  
                new Syncfusion.JavaScript.Models.CustomToolbarItem() { TemplateID = "#Drop" }  
             . . . ..  
        .ClientSideEvents(events => events.DataBound("dataBound")) 
    var filterQuery = [ 
        { text: "Filter EmployeeID lt 5", value: "EmployeeIDlt5" }, 
        { text: "Filter EmployeeID gt 5", value: "EmployeeIDgt5" }, 
        { text: "Clear Filterting", value: "clearFilterting" } 
    function dataBound(args) { 
            dataSource: filterQuery, 
            change: function (args) { 
                var obj = $("#Editing").ejGrid("instance"); 
                if (args.selectedValue == "EmployeeIDlt5") 
                    obj.filterColumn("EmployeeID", "lessthan", 5, "and"); 
                else if (args.selectedValue == "EmployeeIDgt5") 
                    obj.filterColumn("EmployeeID", "greaterthan", 5, "and"); 
                else obj.clearFiltering(); 

Note: To use the filterColumn Grid method, you must enable the AllowFiltering API of the Grid.  

Refer to the following Help Documents. 

We have also prepared a sample that can be downloaded from the following location. 

Seeni Sakthi Kumar S. 


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