bug report for telerik: grid columnMenu bug
by Alex Yu
HTML
<script src="http://cdn.kendostatic.com/2013.2.918/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.918/styles/kendo.common.min.css">
<div style="width: 90%; height: 400px">
<table id="grid" style="width: 100%; heigth: 100%"></table>
</div>
JavaScript
// instructions: open colum menu by clicking on down arrow
// result: Uncaught TypeError: Cannot call method 'replace' of undefined
// analysis: kendoColumnMenu's private var "template" should include a check for .hasOwnProperty in the for..in loop
Function.prototype.method = function (name, func) {
"use strict";
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
} else {
if (window.console) {
console.log("method already defined: " + name);
}
}
};
Array.method('contains', function (object) {
return $.inArray(object, this) !== -1;
});
var localData = [];
var someBool = true;
var someText = "sometext";
for (var i = 0, max_i = 100; i < max_i; i += 1) {
if (i > 10) {
someText = "aText";
}
if (i > 20) {
someBool = false;
}
localData.push({
Id: i,
StatusText: someText,
someBool: someBool
});
if (i % 3 === 0) {
someBool = null;
someText = null;
} else {
someBool = !someBool;
someText = "sometext";
}
}
var dataSource = new kendo.data.DataSource({
data: localData,
schema: {
model: {
fields: {
Id: {
type: "number"
},
StatusText: {
type: "string"
},
someBool: {
type: "boolean"
}
}
}
}
});
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
columnMenu: true,
scrollable: true,
height: 500,
sortable: false,
filterable: true,
groupable: true,
columns: [{
field: "Id",
title: "Id",
filterable: false
}, {
field: "StatusText",
title: "String value"
}, {
field: "someBool",
title: "Boolean value"
}]
}).data("kendoGrid");