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.
Unfortunately, activation email could not send to your email. Please try again.

Edit GRID Row

Thread ID:

Created:

Updated:

Platform:

Replies:

128423 Jan 20,2017 08:51 AM Jan 23,2017 07:33 AM ASP.NET Core 1
loading
Tags: Grid
Nicholas Picardi
Asked On January 20, 2017 08:51 AM

Hi all,

It's possible create a cascading dropdownlist populate with a stored procedure in the edit of the row?

These are my two ddl in edit:

col.Field("MA_StatusCode").HeaderText("Reallocated status code").AllowEditing(true).EditType(EditingType.Dropdown).DataSource((List<object>)ViewBag.alarms).ForeignKeyField("MA_StatusCode").AllowResizing().Width(150).Add();

col.Field("FullDescription").HeaderText("Reallocated Full Description").EditType(EditingType.Dropdown).DataSource((List<object>)ViewBag.FullAlarm).ForeignKeyField("FullDescription").AllowResizing().Width(400).Add();

It's possible?

Thanks,
Nicholas


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On January 23, 2017 07:33 AM

Hi Nicholas, 
 
Thanks for contacting Syncfusion Support.  
 
The Column dataSource will accept only the list of text/value pair as an input. So we suggest to convert the StoredProcedure result to the list of text/value pair and assign them to the corresponding column. Refer to the following code example and API reference. 
 
        public IActionResult Index() 
        { 
            String strConnString = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString; 
            SqlConnection con = new SqlConnection(strConnString); 
            SqlCommand cmd = new SqlCommand(); 
            cmd.CommandType = CommandType.StoredProcedure; 
            cmd.CommandText = "Shipping"; 
            cmd.Connection = con; 
            con.Open(); 
            List<object> dropObj = new List<object>(); 
            using (SqlDataReader dr = cmd.ExecuteReader()) 
            { 
                while (dr.Read()) 
                { 
                    //Convert them to text/value pair 
                    dropObj.Add(new { text = dr.GetValue(0).ToString(), value = dr.GetValue(0).ToString() }); 
                } 
            } 
            con.Close(); 
            ViewBag.dropObj = dropObj; 
            ViewBag.GridData = new NorthwindDataContext().OrdersViews.ToList(); 
            return View(); 
        } 
 
@{Html.EJ().Grid<object>("FlatGrid") 
            .Datasource((IEnumerable<object>)ViewBag.GridData) 
            .AllowPaging() 
            .Columns(col => 
                { 
                        .. .  
                            .. .  
 
                    //Dropdown column 
                    col.Field("ShipCountry").HeaderText("Ship Country") 
                        .DataSource((IEnumerable<object>)ViewBag.dropObj) 
                        .EditType(EditingType.Dropdown).Add(); 
                }).Render(); 
} 
 
 
Note: In this, we have read the Shipping a Stored Procedure and bind ShipCountry column as a text/value pair input to the DropDown DataSource.  
 
We could also have noticed that you have used the foreignkey in your code example but you have missed a ForeignKeyValue API for the corresponding column. To Render the ForeignKey column ForeignKeyValue, ForeignKeyField and DataSource are important for a column. Refer to the following code example and help Documents. 
 
 
@{Html.EJ().Grid<object>("FlatGrid") 
            .Datasource((IEnumerable<object>)ViewBag.GridData) 
            .AllowPaging() 
            .Columns(col => 
                { 
                        .. . 
                              . . . 
 
                    //ForeignKey column 
                    col.Field("EmployeeID").HeaderText("Employee Name") 
                        .ForeignKeyField("EmployeeID") 
                       .ForeignKeyValue("FirstName") 
                       .DataSource((IEnumerable<object>)ViewBag.forObj) 
                       .TextAlign(TextAlign.Left).Add(); 
              
                }).Render(); 
} 
 
 
 
Regards, 
Seeni Sakthi Kumar S. 


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.

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.

;