Skip to content

Commit 84fd844

Browse files
authored
Added CSS class for sorted columns in adminhtml (OpenMage#2604)
1 parent c5c34fc commit 84fd844

File tree

5 files changed

+451
-612
lines changed

5 files changed

+451
-612
lines changed

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,33 @@ public function getGrid()
5555
return $this->_grid;
5656
}
5757

58+
/**
59+
* @return bool
60+
*/
5861
public function isLast()
5962
{
6063
return $this->getId() == $this->getGrid()->getLastColumnId();
6164
}
6265

66+
/**
67+
* @return string
68+
*/
6369
public function getHtmlProperty()
6470
{
6571
return $this->getRenderer()->renderProperty();
6672
}
6773

74+
/**
75+
* @return string
76+
*/
6877
public function getHeaderHtml()
6978
{
7079
return $this->getRenderer()->renderHeader();
7180
}
7281

82+
/**
83+
* @return string|null
84+
*/
7385
public function getCssClass()
7486
{
7587
if (is_null($this->_cssClass)) {
@@ -83,16 +95,26 @@ public function getCssClass()
8395
if ($this->getEditable()) {
8496
$this->_cssClass .= ' editable';
8597
}
98+
// Add css class for sorted columns
99+
if ($this->hasData('dir')) {
100+
$this->_cssClass .= ' sorted';
101+
}
86102
}
87103

88104
return $this->_cssClass;
89105
}
90106

107+
/**
108+
* @return string|null
109+
*/
91110
public function getCssProperty()
92111
{
93112
return $this->getRenderer()->renderCss();
94113
}
95114

115+
/**
116+
* @return string|null
117+
*/
96118
public function getHeaderCssClass()
97119
{
98120
$class = $this->getData('header_css_class');
@@ -102,9 +124,15 @@ public function getHeaderCssClass()
102124
if ($this->isLast()) {
103125
$class .= ' last';
104126
}
127+
if ($this->hasData('dir')) {
128+
$class .= ' sorted';
129+
}
105130
return $class;
106131
}
107132

133+
/**
134+
* @return string
135+
*/
108136
public function getHeaderHtmlProperty()
109137
{
110138
$str = '';
@@ -374,14 +402,16 @@ public function getFilter()
374402
return $this->_filter;
375403
}
376404

405+
/**
406+
* @return string
407+
*/
377408
public function getFilterHtml()
378409
{
379410
if ($this->getFilter()) {
380411
return $this->getFilter()->getHtml();
381-
} else {
382-
return ' ';
383412
}
384-
return null;
413+
414+
return ' ';
385415
}
386416

387417
/**

js/mage/adminhtml/grid.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ varienGrid.prototype = {
5555
for (var row=0; row<this.rows.length; row++) {
5656
if(row%2==0){
5757
Element.addClassName(this.rows[row], 'even');
58+
}else{
59+
Element.addClassName(this.rows[row], 'odd');
5860
}
5961

6062
Event.observe(this.rows[row],'mouseover',this.trOnMouseOver);

0 commit comments

Comments
 (0)