Permalink
Browse files

SD grid: allow a cssClass parameter appliable extra to the cell defau…

…lt cell-{{name}}
  • Loading branch information...
1 parent 274d871 commit 9b546ddc7f7b6a3b5a9c4d29913844010bb340a4 @reebalazs reebalazs committed Mar 11, 2013
Showing with 25 additions and 3 deletions.
  1. +4 −3 substanced/sdi/views/folder.py
  2. +21 −0 substanced/sdi/views/tests/test_folder.py
@@ -144,14 +144,15 @@ def _column_headers(self):
sortable = False
formatter = column.get('formatter', '')
-
+ cssClass = column.get('cssClass', '')
+
headers.append({
- "id": field,
+ "id": field,
"name": name,
"field": field,
"width": 120,
"minWidth": 120,
- "cssClass": "cell-%s" % field,
+ "cssClass": "cell-%s" % field + ((' ' + cssClass) if cssClass else ''),
"sortable": sortable,
"formatterName": formatter,
})
@@ -368,6 +368,27 @@ def test__column_headers_None(self):
result = inst._column_headers()
self.assertEqual(len(result), 0)
+ def test__column_headers_cssClass(self):
+ def sd_columns(folder, subobject, request, default_columns):
+ self.assertEqual(len(default_columns), 1)
+ return [
+ {'name': 'Col 1', 'field': 'col1', 'value':
+ 'col1', 'sortable': True, 'cssClass': 'customClass'},
+ {'name': 'Col 2', 'field': 'col2', 'value': 'col2',
+ 'sortable': True},
+ {'name': 'Col 3', 'field': 'col3', 'value': 'col3',
+ 'sortable': True, 'cssClass': 'customClass1 customClass2'},
+ ]
+ context = testing.DummyResource(is_ordered=lambda: False)
+ request = self._makeRequest(columns=sd_columns)
+
+ inst = self._makeOne(context, request)
+ result = inst._column_headers()
+ self.assertEqual(len(result), 3)
+ self.assertEqual(result[0]['cssClass'], 'cell-col1 customClass')
+ self.assertEqual(result[1]['cssClass'], 'cell-col2')
+ self.assertEqual(result[2]['cssClass'], 'cell-col3 customClass1 customClass2')
+
def test_show_non_filterable_columns(self):
dummy_column_headers = [{
'field': 'col1',

0 comments on commit 9b546dd

Please sign in to comment.