-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRowStyle.js
75 lines (60 loc) · 2.13 KB
/
RowStyle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* This Grid feature adds something that Ext Grids should have had from the start:
* the ability to add custom styling to Grid cells and rows. Yes, as easy as that.
*
* Version 0.9.
*
* Copyright (C) 2011-2012 Alexander Tokarev.
*
* This code is licensed under the terms of the Open Source LGPL 3.0 license.
* Commercial use is permitted to the extent that the code/component(s) do NOT
* become part of another Open Source or Commercially licensed development library
* or toolkit without explicit permission.
*
* License details: http://www.gnu.org/licenses/lgpl.html
*/
Ext.ns('Ext.ux.grid.feature');
Ext.define('Ext.ux.grid.feature.RowStyle', {
extend: 'Ext.grid.feature.Feature',
alias: 'feature.rowstyle',
hasFeatureEvent: false,
/**
* @cfg {String} customRowClass CSS class to add to data row <tr> tag
*/
customRowClass: undefined,
/**
* @cfg {String} customCellClass CSS class to add to data row <td> tag
*/
customCellClass: undefined,
/**
* @cfg {String} customDivClass CSS class to add to data row <div> element inside table cell
*/
customDivClass: undefined,
constructor: function(config) {
var me = this;
Ext.apply(me, config);
me.callParent(arguments);
},
/**
* Injects custom CSS classes in row template.
*/
mutateMetaRowTpl: function(tpl) {
var me = this, // Feature object
trCls = me.customRowClass,
tdCls = me.customCellClass,
divCls = me.customDivClass;
for ( var i = 0, l = tpl.length; i < l; i++ ) {
var chunk = tpl[i];
if ( trCls ) {
chunk = chunk.replace(/(<tr.*class=")([^"]*)/, '$1$2 ' + trCls);
};
if ( tdCls ) {
chunk = chunk.replace(/(<td.*class=")([^"]*)/, '$1$2 ' + tdCls);
};
if ( divCls ) {
chunk = chunk.replace(/(<div.*class=")([^"]*)/, '$1$2 ' + divCls);
};
tpl[i] = chunk;
};
}
});