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
close icon

ComboBox for Grid?

I need to use a ComboBox in the grid as opposed to a DropDownList (Though the user will usually choose from the list, they need to be able to enter free form text).  How is this accomplished using inline editing in the Grid?

Mike

1 Reply

MS Mani Sankar Durai Syncfusion Team January 4, 2017 11:15 AM UTC

Hi Michael, 


Thanks for contacting Syncfusion support. 


We have analyzed your query and based on your requirement we have prepared a sample that can be downloaded from the below link. 



In this sample we have achieved your requirement by using EditTemplate property of columns in grid. In EditTemplate we have rendered Autocomplete control. Also we have enabled the property as showPopupButton to view it as dropdown. 


Please refer the below code example. 

[Index.cshtml] 
@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource) 
        .AllowPaging() 
                           ...                    
            .Columns(col => 
            {               ... 
                col.Field("CustomerID").HeaderText("CustomerID").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).Width(100).Add(); 
}) 
            
) 
 
<script type="text/javascript"> 
    function create() { 
        return $("<input>"); 
    } 
    function write(args) { 
        obj = $('#FlatGrid').ejGrid('instance'); 
        var data = ej.DataManager(obj.model.dataSource).executeLocal(new ej.Query().select("CustomerID")); 
        args.element.ejAutocomplete({ width: "100%", dataSource: data,showPopupButton: true , enableDistinct: true, value: args.rowdata !== undefined ? args.rowdata["CustomerID"] : "" }); 
    } 
    function read(args) { 
        return args.ejAutocomplete("getValue"); 
    } 
</script> 


Also please refer the documentation link. 


Online sample link about EditTemplate, 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Loader.
Live Chat Icon For mobile
Up arrow icon