Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142840 | Feb 21,2019 02:49 PM UTC | Feb 25,2019 11:24 AM UTC | jQuery | 3 |
![]() |
Tags: ejGrid |
<script type="text/javascript">
jQuery(function ($) {
$("#Grid").ejGrid({
//The datasource "window.gridData" is referred from 'http://js.syncfusion.com/demos/web/scripts/jsondata.min.js'
dataSource: [],
toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] },
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
allowPaging: false,
columns: [
{ field: "ID", isPrimaryKey: true, headerText: "ID" },
{ field: "Country", foreignKeyField: "Id", foreignKeyValue: "Name", headerText: "Country", dataSource: locations, editType: "dropdownedit" },
{ field: "Company", foreignKeyField: "Id", foreignKeyValue: "Name", headerText: "Company", dataSource: companies, editType: "dropdownedit" }
],
actionComplete: function (args) {
if (args.requestType === 'add' || args.requestType === 'beginedit') {
$('#GridCountry').ejDropDownList({
dataSource: locations,
fields: { text: "Name", value: "Id" },
watermarkText: 'Select country',
enableFilterSearch: true,
width: '100%'
});
$('#GridCompany').ejDropDownList({
dataSource: companies,
fields: { text: "Name", value: "Id" },
watermarkText: 'Select company',
enableFilterSearch: true,
width: '100%'
});
if (args.requestType == "beginedit") {
var loc = locations.find(c=>c.Id == args.rowData.Country);
var com = companies.find(c=>c.Id == args.rowData.Company);
$('#GridCountry').ejDropDownList("selectItemByValue", com.Id);
$('#GridCompany').ejDropDownList("selectItemByValue", com.Id);
}
}
}
});
});
</script> |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.