<div class="container">
<div id="Grid"></div>
</div>
<script>
$(document).ready(function(){
var data = new ej.data.DataManager({
url: "http://xxxxxxx.xxxxxx/data.php",
adaptor: new ej.data.WebApiAdaptor(),
crossDomain: true
});
ej.grids.Grid.Inject(ej.grids.Edit);
var grid = new ej.grids.Grid({
dataSource: data,
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true
},
pageSettings: { pageCount: 3 },
allowPaging: true,
columns: [
{ field: "ID", headerText: "ID", width: 140, textAlign: "Right", isPrimaryKey: true, visible: false },
{ field: "Menu", headerText: "Menu", width: 140, textAlign: "Right" },
{ field: "Item", headerText: "Item", width: 140, textAlign: "Right", allowEditing: false },
{ field: "Link", headerText: "Link", width: 140, textAlign: "Right" },
{ field: "MenuGroup", headerText: "MenuGroup", width: 140, textAlign: "Right", editType: "dropdownedit", edit: { params: { value: 'Germany' } } },
{ field: "MenuOrder", headerText: "MenuOrder", width: 140, textAlign: "Right" },
{ field: "Seperator", headerText: "Seperator", width: 140, textAlign: "Right" },
{ field: "Security", headerText: "Security", width: 140, textAlign: "Right" },
{ field: "Attr", headerText: "Attr", width: 140, textAlign: "Right" }
],
actionBegin: function(args) {
//alert("Begin");
},
actionComplete: function(args) {
if (args.requestType === 'save') {
var url="include/admin-ajax.php"
formData = new FormData;
formData.append('details', JSON.stringify(args.data));
formData.append('action', 'update-menus');
$.ajax({
url: url,
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response){
result = JSON.parse(response);
alert(result.message);
},
error: function(err) {
alert(err.responseText);
}
});
}
},
});
grid.appendTo('#Grid');
});
</script>