Question
How to change the cell color of the grid in a section?
Answer
- Create the replacing section schema
- Add the prepareResponseCollection() method to the method area of the section schema:
define("ActivitySectionV2", ["GridUtilitiesV2"], function() { return { entitySchemaName: "Activity", contextHelpId: "1001", diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/, messages: {}, methods: { //highlight activity prepareResponseCollection: function(collection) { this.callParent(arguments); var colour = ""; collection.each(function(item) { var type = item.get("UsrType"); if (!this.Ext.isEmpty(type)) { if (type.value === "1192a8c5-7d3d-4c8a-b3ce-8e2f320d64d7") { colour = "#33FF33";//зеленый - FOOTY PARTY } if (type.value === "b8e248b6-e37a-4b21-8377-0c5c6d8bc196") { colour = "#ff33cc"; //розовый - СЧ (Baby) } if (type.value === "20834765-ea57-41d3-8ff9-24e69a70162b") { colour = "#0066ff"; //голубой - СЧ (Boy) } item.customStyle = { background: colour }; item.set("Background", colour); } }, this); }, //field selection in a schedule getGridDataColumns: function() { var baseGridDataColumns = this.callParent(arguments); var gridDataColumns = { "Account": {path: "Account"}, "StartDate": {path: "StartDate"}, "DueDate": {path: "DueDate"}, "ShowInScheduler": {path: "ShowInScheduler"}, "Status": {path: "Status"}, "Status.Finish": {path: "Status.Finish"}, "UsrType": {path: "UsrType"}, "ProcessElementId": { path: "ProcessElementId", dataValueType: 0 } }; return Ext.apply(baseGridDataColumns, gridDataColumns); } } }; });