BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<script>
// Load data in grid
var dataManager = ej.DataManager({
url: "/Grid/DataSource",
updateUrl: "/Grid/Update",
insertUrl: "/Grid/Insert",
removeUrl: "/Grid/Delete",
adaptor: "UrlAdaptor"
});
$("#FlatGrid").ejGrid({
dataSource: dataManager,
actionComplete : "complete",
});
function complete(args) {
if (args.requestType == "beginedit" || args.requestType == "add")
{
var grid = this._id;
$.ajax({
url: '/Grid/EmployeeID',
type: 'GET',
success: function (data1) {
$("#" + grid + "ShipCountry").ejDropDownList({ dataSource: data1 });//assign the dataSource obtained from serverSide
}
});
}
}
</script> |
In the code given by you the drop down
is fixed i.e. "ShipCountry"
but I want to fetch this drop-down id at runtime. Is it possible to check on which cell we have clicked using complete event ? I think on RecordDoubleClick, we get cell information. When the edit type is dropdown then only I have bind dropdown data. so for that I will require source cell and its editing type. Also provide me an example using edit template and ajax function for dropdown.
Thanks.
As per your suggestion, I have tried the
code,
$("#" +
grid + "ShipCountry").ejDropDownList({ dataSource: data1 });
to assign the data source obtained from server side. The code is written on cellEdit
event but it will not bind data source even though it is successfully fetched
by Ajax call.
<script>
// Load data in grid
var dataManager = ej.DataManager({
url: "/Grid/DataSource",
batchUrl: "/Grid/BatchUpdate",
adaptor: "UrlAdaptor"
});
$("#FlatGrid").ejGrid({
dataSource: dataManager,
cellEdit: "cellEdit",
columns: [
{ field: "ShipCountry", headerText: "Ship Country” },
{ field: "ShipCity", headerText: "Ship City" }
],
allowPaging: true
});
function cellEdit(args) {
if (args.columnName == "ShipCountry")
{
var grid = this._id;
$.ajax({
url: '/Grid/EmployeeID',
type: 'GET',
success: function (data1) {
$("#" + grid + "ShipCountry").ejDropDownList({ dataSource: data1 });//assign the dataSource obtained from serverSide
$("#" + grid + "ShipCountry").ejDropDownList("setSelectedText", args.model.selectedRecords[0].ShipCountry);
}
});
}
}
</script> |