Created
October 3, 2012 08:35
-
-
Save LaleWolf/3825814 to your computer and use it in GitHub Desktop.
Anpassung des ListModels auf KendoUI Grid Column Struktur
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
_.mixin({ | |
renameProperties: function (object, translations) { | |
_.each(_.pairs(translations), function(translation) { | |
_.each(object, function(item){ | |
if (item.hasOwnProperty(translation[0])) { | |
item[translation[1]] = item[translation[0]]; | |
delete item[translation[0]]; | |
} | |
return item; | |
}); | |
}); | |
return object; | |
} | |
}); |
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
ListModel | |
"columns": [{ | |
"name": "GUID", | |
"label": "Guid", | |
"datatype": "GuidString" | |
}, { | |
"name": "DESCRIPTION", | |
"label": "Description", | |
"datatype": "String" | |
}], | |
zu | |
columns:[ | |
{ | |
field: "FirstName", | |
title: "First Name" | |
}, | |
{ | |
field: "LastName", | |
title: "Last Name" | |
}], | |
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
Object.prototype.renameProperty = function (oldName, newName) { | |
// Check for the old property name to avoid a ReferenceError in strict mode. | |
if (this.hasOwnProperty(oldName)) { | |
this[newName] = this[oldName]; | |
delete this[oldName]; | |
} | |
return this; | |
}; | |
Array.prototype.renameProperties = function (oldName, newName) { | |
_.each(this, function (elem) { | |
elem.renameProperty(oldName, newName); | |
}; | |
return this; | |
}; |
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
_.mixin({ | |
renameProperties: function (object, oldValue, newValue) { | |
_.each(object, function(item) { | |
item.renameProperty(oldValue, newValue); | |
}); | |
return object; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment