or
custom: function (input) { if (input.is("[name='LogicalName']") && input.val() != "") { $http.post("odata/Entities/IsNameUnique", { logicalName: input.val() }).success(function (data, status, headers, config) { if (!data.value) { input.attr("data-custom-msg", "Name is not unique"); return false } return true;}); } }<script id="itemTemplate" type="text/html"> <div class="children"></div></script><div id="grid"></div>001.var items = [002. { id: 1, name: 'Item 1' },003. { id: 2, name: 'Item 2' }004.];005. 006.var children = {007. '1': [{ id: 1, child: 'Child 1' }, { id: 2, child: 'Child 3' }],008. '2': [{ id: 3, child: 'Child 3' }, { id: 4, child: 'Child 4' }]009.};010. 011.function createChildItemDataSource(item) {012. return new kendo.data.DataSource({013. transport: {014. read: function (options) {015. console.log('children.read: ' + item.id);016. options.success(children[item.id]);017. }018. }019. });020.}021. 022.$('#grid').kendoGrid({023. dataSource: new kendo.data.DataSource({024. transport: {025. read: function (options) {026. // simulate read from server027. var itemsFromServer = items;028. // simulate read from server end029. 030. // create datasource031. for (var i = 0; i < itemsFromServer.length; i++) {032. itemsFromServer[i].dataSource = createChildItemDataSource(items[i]);033. }034. options.success(itemsFromServer);035. console.log('items.read');036. },037. update: function (options) {038. // simulate update on server039. // ....040. // simulate update on server end041. options.success(options.data);042. },043. destroy: function (options) {044. // simulate destroy on server045. for (var i = 0; i < items.length; i++) {046. if (items[i].id === options.data.id) {047. items.splice(i, 1);048. break;049. }050. }051. // simulate destroy on server end052. 053. options.success(options.data);054. },055. create: function (options) {056. // simulate create on server057. var id = 0;058. for (var i = 0; i < items.length; i++) {059. if (items[i].id > id) {060. id = items[i].id;061. }062. }063. options.data.id = id + 1;064. children[options.data.id] = [];065. items.push(options.data);066. // simulate create on server end067. 068. // get data from server069. var itemCreated = options.data;070. 071. itemCreated.dataSource = createChildItemDataSource(options.data);072. options.success(itemCreated);073. }074. },075. schema: {076. model: {077. id: 'id',078. fields: {079. id: { type: 'number', editable: false },080. name: { type: 'string', validation: { required: true } }081. }082. }083. }084. }),085. columns: [{ field: 'id', title: 'ID' }, { field: 'name', title: 'Name' }, { command: ['edit', 'destroy'] }],086. toolbar: ['create'],087. editable: { mode: 'popup' },088. detailTemplate: kendo.template($("#itemTemplate").html()),089. detailInit: function (args) {090. var index = args.masterRow.index('tr.k-master-row');091. 092. console.log('args.masterRow.parent(): ' + args.masterRow.parent().length);093. console.log('args.masterRow[0] === this.table.find(".k-master-row:nth-child(" + (index + 1) + ")")[0]: ' + (this.table.find('.k-master-row:nth-child(' + (index + 1) + ')')[0] === args.masterRow[0]).toString());094. 095. args.detailCell.find('.children').kendoGrid({096. dataSource: args.data.dataSource,097. columns: [{ field: 'id', title: 'ID' }, { field: 'child', title: 'child' }]098. });099. 100. // grid created in args.detailCell101. console.log('grid created in args.detailCell: ' + args.detailCell.find('[data-role="grid"]').length);102. 103. // but args.masterRow is not the same was before104. console.log('args.masterRow[0] === this.table.find(".k-master-row:nth-child(" + (index + 1) + ")")[0]: ' + (this.table.find('.k-master-row:nth-child(' + (index + 1) + ')')[0] === args.masterRow[0]).toString());105. 106. // args.masterRow was removed from dom107. console.log('args.masterRow.parent().length: ' + args.masterRow.parent().length);108. }109.});