Articles in this section
Category / Section

How to enable filter searching in DropDownList editType on Grid column while editing?

3 mins read

If we bound large data source to Grid then Dropdown control popup the list with scroller while editing the JavaScript Grid. In this scenario, users will scroll the Dropdown list to select the appropriate value. It is a tedious process when we bound large data source in Grid and so searching functionality can be enabled in Dropdown. 

Solution:

We can enable the FilterSearch for Dropdownlist while editing the Grid record using actionComplete event of Grid and enableFilterSearch property of Dropdown control.

The following code example demonstrates how to enable the Filter search in Dropdown list while editing the Grid record.

JS

$("#Grid").ejGrid({                
        dataSource: window.gridData,
        allowPaging: true,
        actionComplete:"actionComplete",
        editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
        toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] },
        columns: [
                 { field: "OrderID", isPrimaryKey: true, headerText: "Order ID",  width: 90 },
                 { field: "CustomerID", headerText: "Customer ID",  width: 90 },
                 { field: "EmployeeID", headerText: "Employee ID",  editType: ej.Grid.EditingType.Dropdown, width: 80  },
                 { field: "Freight", headerText: "Freight", width: 80, format: "{0:C2}" }
        ]
    });
  

 

MVC

@(Html.EJ().Grid<object>("Grid")
            .Datasource((IEnumerable<object>)ViewBag.datasource)
            .AllowPaging()    /*Paging Enabled*/
            .ClientSideEvents(ce => ce.ActionComplete("actionComplete "))
            .EditSettings(es => { es.AllowAdding().AllowDeleting().AllowEditing(); })
        .Columns(col =>
        {
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width(90).Add();
            col.Field("CustomerID").HeaderText("Customer ID").Width(90).Add();
            col.Field("EmployeeID").HeaderText("Employee ID").EditType(EditingType.Dropdown).Width(80).Add();
            col.Field("Freight").HeaderText("Freight").Width(80).Format("{0:C2}").Add();
 
        }))
 
 

 

ASP

<ej:Grid ID="Grid" runat="server"  AllowPaging="True" >
            <ClientSideEvents ActionComplete="actionComplete" />
            <Columns>
                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True"  Width="90" />
                <ej:Column Field="CustomerID" HeaderText="Customer ID" Width="90" />
                <ej:Column Field="EmployeeID" HeaderText="Employee ID"  EditType="Dropdown" Width="80" />
                <ej:Column Field="Freight" HeaderText="Freight"  Width="80" Format="{0:C2}"  />                
            </Columns>
            <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
            <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
 
        </ej:Grid>

 

.Net core

<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.DataSource" action-complete="actionComplete">
    <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true"></e-edit-settings>
    <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' />
    <e-columns>
        <e-column field="OrderID" is-primary-key="true" header-text="Order ID" width="90"></e-column>
        <e-column field="CustomerID" header-text="CustomerID" width="90"></e-column>
        <e-column field="EmployeeID" header-text="Employee ID" width="80" edit-type="DropdownEdit"></e-column>
        <e-column field="Frieght" header-text="Freight" width="80" format="{0:C2}"></e-column>        
    </e-columns>
</ej-grid>

 

Angular

<ej-grid #grid id="Grid" [dataSource]="gridData" allowPaging="true" (actionComplete)="actionComplete($event)" [toolbarSettings]="toolbarItems" [editSettings]="editSettings">
    <e-columns>
        <e-column field="OrderID" [isPrimaryKey]="true" headerText="OrderID" width="90"></e-column>
        <e-column field="CustomerID" headerText="CustomerID" width="90"></e-column>
        <e-column field="EmployeeID" headerText="EmployeeID" editType="dropdownedit" width="80"></e-column>
        <e-column field="Freight" headerText=" Freight " format="{0:C2}" width="90"></e-column>        
    </e-columns>
</ej-grid>
 
 

TS file

@ViewChild('grid') GridModel: EJComponents<any, any>;
 
actionComplete(e:any){
 
if (e.requestType == "beginedit" || e.requestType == "add") {
            var gridID = this.GridModel.widget._id;//Get the corresponding Grid ID
            var dropdownObj = $("#" + gridID+ "EmployeeID").ejDropDownList('instance'); /* Get the object of EmployeeId column ejDropDownList */
 
            dropdownObj.option({enableFilterSearch:true, value: e.rowData.EmployeeID });  /*Enable the filtersearch property to the ejDropDownList control.*/
}

 

JS

function actionComplete(args) {
 
        if (args.requestType == "beginedit" || args.requestType == "add") {
 
            var dropdownObj = $("#" + this._id + "EmployeeID").ejDropDownList('instance'); /* Get the object of EmployeeId column ejDropDownList */
 
            dropdownObj.option({ enableFilterSearch: true, value: args.rowData.EmployeeID });/*Enable the filtersearch property to the ejDropDownList control.*/
        }
}

 

Output:

 

 

Conclusion

I hope you enjoyed learning about how to enable filter searching in DropDownList editType on Grid column while editing.

You can refer to our JavaScript Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our JavaScript Grid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied