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. Image for the cookie policy date

ejGrid, edit template fill a dropdown from a different source

we are using Version=12.3400.0.36 of the ej:Grid, when editing I need one of the dropdowns to have values filled at page load with values for the users allowed to have.

I found a simple example from one of the Forum posts so I tried this:
private void BindDataSource()
{
    bike.Add(new Bikes(1, "Harley"));
    bike.Add(new Bikes(2, "Indian"));
    bike.Add(new Bikes(3, "Honda"));

    int code = 10000;
    for (int i = 1; i < 10; i++)
    {
order.Add(new Orders(code + 1, "ALFKI", i + 0, 2.3 * i, new DateTime(1991, 05, 15), "Berlin"));
order.Add(new Orders(code + 2, "ANATR", i + 2, 3.3 * i, new DateTime(1990, 04, 04), "Madrid"));
order.Add(new Orders(code + 3, "ANTON", i + 1, 4.3 * i, new DateTime(1957, 11, 30), "Cholchester"));
order.Add(new Orders(code + 4, "BLONP", i + 3, 5.3 * i, new DateTime(1930, 10, 22), "Marseille"));
order.Add(new Orders(code + 5, "BOLID", i + 4, 6.3 * i, new DateTime(1953, 02, 18), "Tsawassen"));
code += 5;
    }
    this.FlatGrid.DataSource = order;

    var index = this.FlatGrid.Columns.FindIndex(col => col.Field == "Delivery");
    this.FlatGrid.Columns.ElementAt(index).DataSource = bike;

    this.FlatGrid.DataBind();
}

there where no aspx changes noted.
when I ran the code I got:
JavaScript runtime error: DataManger : a dataSource is required to create Manager
Error: DataManger : a dataSource is required to create Manager
   at u (http://localhost:60455/Scripts/ej/ej.web.all.min.js:10:69085)
   at t.DataManager (http://localhost:60455/Scripts/ej/ej.web.all.min.js:10:18935)
   at t.DataManager (http://localhost:60455/Scripts/ej/ej.web.all.min.js:10:18900)
   at complete (http://localhost:60455/Default.aspx:131:17)
   at t.widgetBase._trigger (http://localhost:60455/Scripts/ej/ej.web.all.min.js:10:8510)

I do not see any example using a list or other local data binding in this way.

Thanks;

Attachment: Grid_a6959885.zip

3 Replies

SR Sellappandi Ramu Syncfusion Team January 6, 2016 09:55 AM UTC

Hi Bruce,

Thanks for contacting Syncfusion support.

We have tested the reported issue in provided sample and found that you have not properly rendered dataSource to dropdown list, the server data for dropdown is defined as “BikeID”  and “Text” pair which is the cause of the issue. While binding data to dropdown list, data should be “text” and “value” pair. And While using dialog template datasource should set for dropdown in actionBegin event.

Please refer to the code example,


if (args.requestType == "beginedit") {

                    $("#OrderID").attr("disabled", "disabled");

                    $("#ShipCity").ejDropDownList({ width: '116px', change: "_Change" }).ejDropDownList("setSelectedValue", args.row.children().eq(5).text());

                   

                    //var gobj = $("#Agacent").ejGrid("instance")

                    //gobj.gridObj.dataSource(data);


                    $("#Agacent").ejDropDownList({ width: '116px', dataSource: this.model.columns[6].dataSource }).ejDropDownList("setSelectedValue", args.row.children().eq(6).text());

                }

                else

                    $("#ShipCity").ejDropDownList({ width: '116px', change: "_Change" });

               

            }

[Server side]

[Serializable]

        public class Bikes

        {

            public Bikes()

            {


            }

            public Bikes(long Bike, string text)

            {

                this.value = Bike;

                this.text = text;

            }

            public long value { get; set; }

            public string text { get; set; }
        }


Regards,
Sellappandi R


BS Bruce Stevenson January 6, 2016 01:53 PM UTC

thank you  for identifying the datasource it has fixed the issue.
I have made the changes to the class and now see the data for selection.


again Thanks for the support.




SR Sellappandi Ramu Syncfusion Team January 7, 2016 08:51 AM UTC

Hi Bruce,

Thanks for the update.

Please get back to us if you have any queries. We are happy to assist you.

Regards,
Sellappandi R

Loader.
Live Chat Icon For mobile
Up arrow icon