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

DropDownBox in Grid displays first Item when adding new record?

Thread ID:

Created:

Updated:

Platform:

Replies:

127675 Dec 1,2016 06:54 PM UTC Dec 2,2016 12:29 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Michael Lambert
Asked On December 1, 2016 06:54 PM UTC

When I add a new record in a grid the DropDownBox displays the first item and not just a blank box.  I just want a blank box and if the user doesn't make a selection have it just remain blank/null.  It's a optional field anyways.

Mani Sankar Durai [Syncfusion]
Replied On December 2, 2016 12:29 PM UTC

Hi Michael, 


Thanks for contacting Syncfusion support. 


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

 
 
By default when adding the records in grid it will show the blank value for the dropdown columns and if user doesn’t select anything it will remains blank value. Suppose, if you set DefaultValue property for that particular column then it will shows that value while adding a record. 
 
 
To show the dropdown value as blank value or null we suggest you to pass the empty data to the dropdown datasource initially when binding or by using addItem method in dropdown(when DefaultValue is set). Using selectItemByText we can able to make the dropdown value as null when user doesn’t select any items. 
 
 
Please refer the below code example. 

[index.cshtml] 
@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("Grid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource) 
        .AllowPaging() 
...                .ClientSideEvents(eve => eve.ActionComplete("complete")) 
        .Columns(col => 
            { 
                ... 
             }) 
              ) 
 
<script> 
     
    function complete(args) { 
       if (args.requestType == 'add') { 
            var dropdown = $("#GridEmployeeID").ejDropDownList("instance"); 
            $('#GridEmployeeID').ejDropDownList("addItem", { text: "" }); 
            dropdown.selectItemByText(""); 
           } 
    } 
</script> 



From the above code example, we have pass the empty data to the dropdown datasource for the particular column and by using selectItembyText or index we can get the blank value in dropdown. 

Please refer the documentation link. 



If you still face the issue please get back to us with the following details, 
1.       Share the screenshot of the issue that you have faced. 
2.       Share the full grid code. 
3.       Share the datasource for the dropdown. 
4.       If possible please reproduce the issue in the above attached sample. 
The provided information will help us to analyze the issue and provide you the response as early as possible. 

Please let us know if you need further assistance. 


Regards, 
Manisankar Durai. 


CONFIRMATION

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.

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

;