Working with a Kendo grid, I need a method that checks data for a specific cell on the grid. I want to return the column name of which the cell is located on. The columns have a static field name, but dynamic title. I need to retrieve the title, based on the field name.
Code:
function checkAllTemperatures(data) {
var columns = ['Temp1','Temp2','Temp3','Temp4','Temp5'];
var comment = '';
for (var i = 0; i < columns.length; i++) {
comment += checkTemperature(data, columns[i]) + ', ';
}
//removes trailing comma and whitespace from comment
comment = comment.replace(/,\s*$/, "");
setComment(data, comment);
}
function checkTemperature(data, columnName) {
var comment = '';
var matlSpec = GetMaterialSpecs(data.ProductId);
var changedData = data[columnName];
if(changedData > matlSpec.TemperatureUpperLimit || changedData < matlSpec.TemperatureLowerLimit)
{
var columnTitle = grid.columns.find(function(v, i) { return grid.columns[i].field == columnName; }).title;
comment = columnTitle + ' = ' + changeData;
CommonFunctions.OpenErrorWindow({message: 'Temp is out of specification!', Errors:'', errors:''});
}
return comment;
}
When debugging in Google Chrome, running this command in the console: grid.columns.find(function(v, i) { return grid.columns[i].field == "Temp1"; }).title
returns the correct title, but when running in IE11 I get this error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'find'
Dispite that command working in the Chrome Console, when actually running the program chrome gives this error:
Uncaught ReferenceError: changeData is not defined
Ideas of why this code breaks:
1) Jquery is being initialized twice because of the kendo grid, breaking it.
2) .find() is not supported by IE11
Any ideas to fix?
You can find a polyfill for the Array.find method towards the bottom of this page. Array.find is not supported by IE at any point. Edge does support it though.
User contributions licensed under CC BY-SA 3.0