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.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

124714 Jun 24,2016 05:47 AM Jun 29,2016 09:22 AM JavaScript 3
loading
Tags: ejGrid
Prashant Prasad
Asked On June 24, 2016 05:47 AM


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.



Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On June 27, 2016 08:37 AM

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. 


Prashant Prasad
Replied On June 28, 2016 06:21 AM

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

Prasanna Kumar Viswanathan [Syncfusion]
Replied On June 29, 2016 09:22 AM

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 

  


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.

;