Created
October 17, 2016 20:35
-
-
Save RawSanj/3f28f59acfa1b68d585d96ae89526c1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css" rel="stylesheet" type="text/css" /> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.rtl.min.css" rel="stylesheet" type="text/css" /> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.default.min.css" rel="stylesheet" type="text/css" /> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" /> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.dataviz.default.min.css" rel="stylesheet" type="text/css" /> | |
<link href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" /> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.all.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="grid"></div> | |
<script> | |
expandHierarchy1Row = null; | |
$(document).ready(function() { | |
var crudServiceBaseUrl = "http://demos.kendoui.com/service", | |
dataSource = new kendo.data.DataSource({ | |
transport: { | |
read: { | |
url: crudServiceBaseUrl + "/Products", | |
dataType: "jsonp" | |
}, | |
update: { | |
url: crudServiceBaseUrl + "/Products/Update", | |
dataType: "jsonp" | |
}, | |
destroy: { | |
url: crudServiceBaseUrl + "/Products/Destroy", | |
dataType: "jsonp" | |
}, | |
create: { | |
url: crudServiceBaseUrl + "/Products/Create", | |
dataType: "jsonp" | |
}, | |
parameterMap: function(options, operation) { | |
if (operation !== "read" && options.models) { | |
return {models: kendo.stringify(options.models)}; | |
} | |
} | |
}, | |
batch: true, | |
pageSize: 20, | |
schema: { | |
model: { | |
id: "ProductID", | |
fields: { | |
ProductID: { editable: false, nullable: true }, | |
ProductName: { validation: { required: true } }, | |
UnitPrice: { type: "number", validation: { required: true, min: 1} }, | |
Discontinued: { type: "boolean" }, | |
UnitsInStock: { type: "number", validation: { min: 0, required: true } } | |
} | |
} | |
} | |
}); | |
var element = $("#grid").kendoGrid({ | |
dataSource: dataSource, | |
height: 430, | |
sortable: true, | |
pageable: true, | |
toolbar: ["create", "save", "cancel"], | |
editable: "inline", | |
edit: function(e){ }, | |
detailInit: detailInit, | |
detailCollapse: function(e){console.log("collapsed!")}, | |
detailExpand: function(e){ | |
//alert(); | |
}, | |
save: function(e){ | |
e.preventDefault(); | |
if (confirm("Do you want to add a new hierarchy2?")) { | |
expandHierarchy1Row = e.model.uid; | |
} | |
this.saveChanges(); | |
}, | |
dataBound: function() { | |
if (expandHierarchy1Row) { | |
var row = this.tbody.find("[data-uid='"+expandHierarchy1Row+"']"); | |
var data = this.dataItem(row); | |
this.expandRow(row); | |
} | |
}, | |
columns: [ | |
{ field: "ProductName", width: "410px"}, {command: ["edit"]} | |
] | |
}); | |
}); | |
function detailInit(e) { | |
console.log("detailInit"); | |
var id = this.dataItem(e.masterRow).ProductID; | |
$("<div id='hierarchy1_"+id+"'/>").appendTo(e.detailCell).kendoGrid({ | |
dataBound: function(e){ | |
if (expandHierarchy1Row) { | |
var grid = this; | |
expandHierarchy1Row = null; | |
setTimeout(function(){grid.addRow();}); | |
} | |
}, | |
dataSource: { | |
type: "odata", | |
transport: { | |
read: "http://demos.kendoui.com/service/Northwind.svc/Orders", | |
update: "http://demos.kendoui.com/service/Northwind.svc/Orders", | |
create: "http://demos.kendoui.com/service/Northwind.svc/Orders", | |
destroy: "http://demos.kendoui.com/service/Northwind.svc/Orders" | |
}, | |
schema: { | |
model: { | |
id: "OrderID", | |
fields: { | |
EmployeeID: { type: "number", defaultValue: e.data.ProductID }, | |
OrderID: { type: "number" }, | |
Freight: { type: "number" }, | |
ShipName: { type: "string" }, | |
OrderDate: { type: "date" }, | |
ShipCity: { type: "string" } | |
} | |
} | |
}, | |
serverPaging: true, | |
serverSorting: true, | |
serverFiltering: true, | |
pageSize: 5, | |
filter: { field: "EmployeeID", operator: "eq", value: e.data.ProductID } | |
}, | |
scrollable: false, | |
sortable: true, | |
pageable: true, | |
toolbar: ["create", "save", "cancel"], | |
editable: "popup", | |
columns: [ | |
{ field: "OrderID", width: "70px" }, | |
{ field: "ShipCountry", title:"Ship Country", width: "110px" }, | |
{ field: "ShipAddress", title:"Ship Address" }, | |
{ field: "ShipName", title: "Ship Name", width: "200px" } | |
] | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.telerik.com/forums/kendo-grid-popup-editor-closes-immediately-on-manual-addrow