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
close icon

Unable to set selected value of a drop down in the bind cell in edit mode.


I have created ejGrid and assigned different validation rules like required,.. on cells before edit mode. I have modified different cells from textbox to dropdown on cell edit event.  When I select the value from drop down it won't get stored in the cell which is bind by drop down. So that every time it shows me required validation message even though it has value. 
    My cell edit event code is like below,

function cellEdit(args) {
        var vfield = args.columnObject.field;
        var vEditType = args.columnObject.editType;
        var ViewId = $("#hfViewID").val();
        var SyncfusionGrid = 2;

        if(vEditType == "dropdownedit") {
            var grid = this._id;
            $.ajax({
                url: window.applicationBaseUrl + 'Controller/GetDropDownValue/',
                data: {
                    fldKnownName: vfield,
                    viewId: ViewId,
                    gridType: SyncfusionGrid
                },
                type: 'GET',
                success: function (dropDownData) {
                    dropDownData = "[" + dropDownData + "];";
                    $("#" + grid + vfield).ejDropDownList({
                        dataSource: eval(dropDownData),
                        fields: {key: "text", text: "value" }
                    });

                    $("#" + grid + vfield).ejDropDownList("setSelectedText", args.model.selectedRecords[0][vfield]);
                }
            });
        }
    }
Thanks.



3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team June 27, 2016 12:37 PM UTC

Hi Prashant, 

We are unable to reproduce the issue at our end. We have prepared a sample with the given information that can be downloaded from the following location. 


<div id="Grid"></div> 
 
<script type="text/javascript"> 
    $(function () { 
        var gridData = [ 
                 . . .. 
        ] 
        $("#Grid").ejGrid({ 
            dataSource: gridData, 
               . . . 
            cellEdit: function (args) { 
                var vfield = args.columnObject.field; 
                var vEditType = args.columnObject.editType; 
                var ViewId = $("#hfViewID").val(); 
                var SyncfusionGrid = 2; 
 
                if (vEditType == "dropdownedit") { 
                    var grid = this._id; 
                    $.ajax({ 
                        url: "/Home/Data", 
                        data: { 
                            fldKnownName: vfield, 
                            viewId: ViewId, 
                            gridType: SyncfusionGrid 
                        }, 
                        type: 'GET', 
                        success: function (dropDownData) { 
                            $("#" + grid + vfield).ejDropDownList({ 
                                dataSource: eval(dropDownData), 
                                fields: { key: "EmployeeID", text: "FirstName" } 
                            }); 
 
                            $("#" + grid + vfield).ejDropDownList("setSelectedText", args.model.selectedRecords[0][vfield]); 
                        } 
                    }); 
                } 
            }, 
 
        }); 
    }); 
 
</script> 

We suggest to ensure the returned data is having text and value fields and also check whether it contains the vfield a value which is previously bound data to the corresponding column. If you are still facing any issue, please get back to us with the following information to analyze the issue. 

1)      Show returned data from the server-side (like the image shown) 
 
 
 
2)      Code example of entire Grid. 
3)      If possible, you can also modify the sample and replicate the issue 

Regards, 
Seeni Sakthi Kumar s. 



PP Prashant Prasad June 28, 2016 10:21 AM UTC

I have bind dropdownlists in edit mode only. Also I have fetched data for dropdown lists using Ajax call.  And on the cell edit event, I want to take one of value from down down list and move ahead to next cell using mouse.

In my example, the vfield contains value either "Country" or "State" because these are the columns of ejGrid. Find data source for each, ejGrid, ejDropDownList in attached zip file. The below code properly binds data source to dropdownlist and also show the selected text but at the time loosing focus from the cell, it triggers validation message even though data is present in the cell. As per data source for ejDropDownList, I have written following code,

 

            var grid = this._id;

            $.ajax({

                url: window.applicationBaseUrl + 'Controller/GetDropDownValue/',

                data: {

                    fldKnownName: vfield,

                    viewId: ViewId,

                    gridType: SyncfusionGrid

                },

                type: 'GET',

                success: function (dropDownData) {

                    dropDownData = "[" + dropDownData + "];";

                    $("#" + grid + vfield).ejDropDownList({

                        dataSource: eval(dropDownData),

                        fields: {key: "text", text: "value" }

                    });

 

                    $("#" + grid + vfield).ejDropDownList("setSelectedText", args.model.selectedRecords[0][vfield]);

                }

            });


Attachment: Dropdown_issue_74ab0a43.rar


PK Prasanna Kumar Viswanathan Syncfusion Team June 29, 2016 01:22 PM UTC

Hi Prasad, 

Thanks for the update. 

We checked in our sample with attached datasource and the validation message does not triggered when we navigate to next cell after select the value from the dropdown. 

To reproduce the issue we need the following details. 

1.       Purpose of this code (dropDownData = "[" + dropDownData + "];). When we use this code we faced the script error while select the dropdown. 
 
2.       Essential Studio Version. 
 
3.       Screenshot of an issue. 
 
4.       Replicate the issue in the attached sample. 
 

Regards, 
Prasanna Kumar N.S.V 

  


Loader.
Live Chat Icon For mobile
Up arrow icon