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

How to include a blank or null value from a foriegn key column?

Thread ID:





127391 Nov 11,2016 10:31 PM UTC Nov 14,2016 02:22 PM UTC ASP.NET MVC 1
Tags: Grid
R Brian Lindahl
Asked On November 11, 2016 10:31 PM UTC

I have a column like this:

                    .HeaderText("Deliver to")


This is an optional field, so there isn't necessarily a value in DeliverToID, and it might be necessary for the field to be set back to null if it _did_ have a value. Is there a way to include a blank item at the top of the dropdown list to allow setting the value back to null?

Karthick Kuppusamy [Syncfusion]
Replied On November 14, 2016 02:22 PM UTC

Hi Brian, 

Thanks for Contacting Syncfusion support. 

We have analyzed your requirement and we have achieved your requirement through the edit template feature of the grid. 

Edit Template has three functions. 
Create – It is used to create the control at time of initialize 
Read –  It is used to read the input value at time of save 
Write – It is used to assign the value to control at time of editing 
Please refer the below code snippet for further details. 
            .AllowPaging()    /*Paging Enabled*/ 
             .ClientSideEvents(eve => { eve.ActionComplete("actionbegin"); }) 
              .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
              .ToolbarSettings(toolbar => 
                    toolbar.ShowToolbar().ToolbarItems(items => 
                .ClientSideEvents(e => e.QueryCellInfo("actionComplete")) 
        .Columns(col => 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).DataSource((IEnumerable<object>)ViewData["LocalDataSource"]).TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true)).Add(); 
            col.Field("OrderDate").HeaderText("Order Date").Format("{0:dd/MM/yyyy}").TextAlign(TextAlign.Right).Width(80).Add(); 
            col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); 
        var items = [{ 
            text: "ALF", 
            value: "ALFKI" 
        }, { 
            text: "ANA", 
            value: "ANATR" 
        }, { 
            text: "ARO", 
            value: "AROUT" 
            text: "BON", 
            value: "BONAP" 
        }, { 
            text: "", 
            value: "BOTTM" 
            text: "ANT", 
            value: "ANTON" 
        }, { 
            text: "BER", 
            value: "BERGS" 
        function create() { 
            return $("<input>"); 
        function write(args) { 
            args.element.ejDropDownList({ width: "100%", dataSource:items,fields: { text: "text", value: "value" }, enableSorting: true, value: args.rowdata !== undefined ? args.rowdata["CustomerID"] : "" });//dropdownlist 
        function read(args) { 
            return args.ejDropDownList("getValue"); 

Please refer the below UG Documentation and online demo link to know further details about EditTemplate in Grid. 

If we misunderstood your requirement then could you please share more details about your requirement. 



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