Trying to add a null value in editType="dropdownedit"

<e-grid-column field="OriginId" headerText="Origin" foreignkeyField="Id" foreignkeyValue="Number" editType="dropdownedit" dataSource="@ViewBag.locs" width="40"></e-grid-column>

I'm trying to figure out how to add a 'null' value to this dropdown. If a user selects an item from the drop down.. saves it, but then that particular item changes to nothing. you cannot remove it within the datagrid. As it shows all the value's from the ViewBag. And not a default "NULL" value at the top.


3 Replies

RR Rajapandi Ravi Syncfusion Team November 29, 2021 12:09 PM UTC

Hi Steven, 

Greetings from Syncfusion support 

From your update we could see that you like to add a null value in the Foreignkey dropdown datasource. Based on your query we have prepared a sample and achieved your requirement. Please refer the below code example and sample for more information. 


<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel","Search" })" height="420"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Delete"></e-data-manager> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" isPrimaryKey="true" headerText="Order ID" type="number" textAlign="Right" width="120"></e-grid-column> 
        <e-grid-column field="EmployeeID" foreignKeyField="EmployeeID" foreignKeyValue="ShipName" headerText="Ship Name" dataSource="@ViewBag.DataSource2" width="200"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 



public static List<OrdersData> 
            GetAllRecords() 
        { 
            if (order1.Count() == 0) 
            { 
                int code = 10; 
                for (int i = 1; i < 5; i++) 
                { 
                    order1.Add(new OrdersData(code + 1, 16, 11, code + 1, " Alizet"+i, "Zen. Jelivia 12")); 
                    order1.Add(new OrdersData(code + 1, 10, 15, code + 2, null, "Avda. Azteca 123")); 
                    order1.Add(new OrdersData(code + 2, 15, 29, code + 3, "Frankenversand"+i, "Carrera 52 con Ave. Bolívar #65-98 Llano Largo")); 
                    order1.Add(new OrdersData(code + 3, 18, 30, code + 4, " Handel"+i, "Magazinweg 7")); 
                    order1.Add(new OrdersData(code + 4, 22, 25, code + 5, " Carnes"+i, "1029 - 12th Ave. S.")); 
                    code += 5; 
                } 
            } 
            return order1; 
        } 



Screenshot: 

 


If you still face the issue, please share the below details that will be helpful for us to provide better solution. 

1)             Please share your syncfusion package version. 

2)             Share your exact requirement with detailed description. 


Rajapandi R 



ST Steven December 1, 2021 08:54 PM UTC

I'm using the latest syncfusion package version 19.3.0.56

I'm wanting to add a Blank value or a "Please Select" at the first selection of the dropdown list. So you are able to select nothing for that column.



RR Rajapandi Ravi Syncfusion Team December 2, 2021 12:50 PM UTC

Hi Steven, 

Thanks for the update 

Before we start providing solution on your query, we need some information for our clarification. Please share the below details that will be helpful for us to provide better solution. 

1)             Please confirm you like to add a Blank value is in 1st position in the dropdown datasource. 

2)             If not please share your exact requirement with detailed description. 

3)            If possible, explain your requirement scenario with pictorial representation. 


Rajapandi R 


Loader.
Up arrow icon