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.

How to set DropDownDataSource when using GridPropertiesModel?

Thread ID:

Created:

Updated:

Platform:

Replies:

116129 Apr 9,2014 03:10 AM Apr 11,2014 07:00 AM ASP.NET MVC (Classic) 2
loading
Tags: Grid
Laszlo Boross
Asked On April 9, 2014 03:10 AM

Hi All,

Is anyone able to provide a sample of a Grid with a column that has a CellEditType of DropdownEdit and is bound to a data source using DropDownDataSource but using the GridPropertiesModel?

I construct my GridPropertiesModel like this, I can see that the data source for the column is correctly populated in the view, (List of strings) but the dropdown is still empty...

 GridPropertiesModel<DataRow> model = new GridPropertiesModel<DataRow>()
            {
                ActionMode = ActionMode.JSON,
                DataSource = m_API.execQuery("select * from TEST").AsEnumerable()
            };

            GridEditing edit = new GridEditing()
            {
                AllowNew = true,
                EditMode = GridEditMode.Normal,
                AllowEdit = true,
                AllowDelete = true,
                PrimaryKey = new List<string> { "ID" }
            };

model.Columns = new List<GridColumn<DataRow>>
            {
                new GridColumn<DataRow>
                {
                    HeaderText = "Column A",
                    MappingName = "ID"
                },
                new GridColumn<DataRow>
                {
                    HeaderText = "Column B",
                    MappingName = "COLUMN1",
                    CellEditType = CellEditType.DropdownEdit
                },
                new GridColumn<DataRow>
                {
                    HeaderText = "Column C",
                    MappingName = "TYTY1",
                    CellEditType = CellEditType.DropdownEdit,
                    DropDownDataSource = new List<string> { "AAA", "BBB", "CCC", }
                },
            };

Much appreciated, Laz


Laszlo Boross
Replied On April 9, 2014 10:29 PM

I have isolated the issue to the fact that I am binding to a DataTable/DataRow instead of an EF Entity...

If I change my Grid to bind to the entity 'INSTANCE', the dropdown populates as expected...

public ActionResult GridEdit6(int id)
        {
            IEnumerable data = m_DS.INSTANCES.ToList();

            GridPropertiesModel<INSTANCE> model = new GridPropertiesModel<INSTANCE>()
            {
                ActionMode = ActionMode.JSON,
                DataSource = data
            };

            GridEditing edit = new GridEditing()
            {
                AllowNew = true,
                EditMode = GridEditMode.Normal,
                AllowEdit = true,
                AllowDelete = true,
                PrimaryKey = new List<string> { "ID" },
            };

            model.Editing = edit;

            model.Columns = new List<GridColumn<INSTANCE>>
            {
                new GridColumn<INSTANCE>
                {
                    HeaderText = "Column A",
                    MappingName = "ID"
                },
                new GridColumn<INSTANCE>
                {
                    HeaderText = "Column B",
                    MappingName = "DB_VERSION",
                    CellEditType = CellEditType.DropdownEdit
                },
                new GridColumn<INSTANCE>
                {
                    HeaderText = "Column C",
                    MappingName = "PDB",
                    CellEditType = CellEditType.DropdownEdit,
                    DropDownDataSource = (Array)new string[] { "AAA", "BBB", "CCC", "DDD", }
                }
            };

            ViewData["GridModel"] = model;

            return View();

        }


My View is defined as below:


@model Essatto5.API.INSTANCE
@{
    ViewBag.Title = "Home Page";
}

<br />

<div>
    @( Html.Syncfusion().Grid<Essatto5.API.INSTANCE>("ViewGrid6", (GridPropertiesModel<Essatto5.API.INSTANCE>)ViewData["GridModel"]))
</div>


Any assistance is appreciated, Laz


Alan Sangeeth S [Syncfusion]
Replied On April 11, 2014 07:00 AM

Hi Laszlo,

We are able to reproduce the issue “In DataTable, DropDown is empty while editing ”, to get a solution for this behavior, please contact us at Syncfusion Support or you may also open a support ticket by login in to direct trac account and mention this forum link for reference.

Regards,

Alan Sangeeth 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.

;