BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<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> |
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]);
}
});