ejdropdown ejdatamanager calling api twice and showing values doubles

Hi,

I am using ejgrid and on inline edit i am dynamically location the values of drop down.

my datamager is calling the API twice i have checked via keeping a debug at API controller method and my dropdown values are populatin each value two times.

i Have attached my sample code with debugger images for your reference 

Appreciate your early response for the fix of the same.

Regrads,
Hirnesh Jain



Attachment: SyncfusionTest_e307211.rar

1 Reply

KR Keerthana Rajendran Syncfusion Team May 22, 2018 07:09 AM UTC

Hi Hirnesh,      
   
Thank you for using Syncfusion products.   
   
We have prepared a sample based on your scenario and able to reproduce the issue at our end. WebApi controller method is hit twice because while setting dataSource and fields dynamically, the properties will be executed one by one via setModel. So WebApi method is hit for dataSource first and then for fields. We suggest you to set DropDownList fields during initial rendering of Grid as shown below and assign dataSource alone during edit or add. Please refer to the below given code.   
   
@(Html.EJ().Grid<Object>("FlatGrid")   
                    .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.DataSource).Adaptor(AdaptorType.RemoteSaveAdaptor))   
                    .AllowPaging()   
                    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Normal); })   
                    .ToolbarSettings(toolbar =>   
                    {   
                        toolbar.ShowToolbar().ToolbarItems(items =>   
                        {   
                            items.AddTool(ToolBarItems.Add);   
                            items.AddTool(ToolBarItems.Edit);   
                            items.AddTool(ToolBarItems.Delete);   
                            items.AddTool(ToolBarItems.Update);   
                            items.AddTool(ToolBarItems.Cancel);   
                        });   
                    })   
                    .Columns(col =>   
                    {   
                        col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Add();   
                        col.Field("CustomerID").HeaderText("Customer ID").EditType(EditingType.String).Add();   
                        col.Field("Freight").HeaderText("Freight").EditType(EditingType.Numeric).NumericEditOptions(new EditorProperties() { DecimalPlaces = 2 }).Add();   
                        col.Field("ShipCountry").HeaderText("Ship Country").DropDownEditOptions(new DropDownListProperties() { DropDownListFields = { Text = "OrderID", Value = "CustomerID" } }).EditType(EditingType.Dropdown).Add();   
                       col.Field("OrderDate").HeaderText("Order Date").EditType(EditingType.Datepicker).Format("{0:MM/dd/yyyy}").Add();   
                    }).ClientSideEvents(eve => { eve.ActionComplete("complete"); }))   
   
    <script type="text/javascript">   
        function complete(args) {   
            var dataManager = ej.DataManager({   
                url: "/api/Orders",   
                adaptor: new ej.WebApiAdaptor(),   
                crossDomain: true,   
            });   
            if ((args.requestType == "beginedit" || args.requestType == "add")) {   
   
                $("#FlatGridShipCountry").ejDropDownList({   
                    dataSource: dataManager   
                });   
                $(".e-field").css({ 'width''116px''text-align''left' });   
            }   
   
        }   
   
    </script>   
     
   
   
We have attached a sample for your reference which can be downloaded from the below link.   
   
   
Regards,   
Keerthana.   


Loader.
Up arrow icon