mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added correct styling of sorting and odd even on grid table
This commit is contained in:
parent
b1b1615a58
commit
488734e53e
@ -67,14 +67,17 @@ class DatagridPresenter extends ViewableData {
|
|||||||
*
|
*
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
function Items() {
|
public function Items() {
|
||||||
$fieldItems = new ArrayList();
|
$fieldItems = new ArrayList();
|
||||||
if($items = $this->datagrid->datasource) {
|
if($items = $this->getDatagrid()->getDatasource()) {
|
||||||
|
$counter = 0;
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
if(!$item) {
|
if(!$item) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$fieldItems->push(new $this->itemClass($item, $this));
|
$datagridPresenterItem = new $this->itemClass($item, $this);
|
||||||
|
$datagridPresenterItem->iteratorProperties($counter++, $items->count());
|
||||||
|
$fieldItems->push($datagridPresenterItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $fieldItems;
|
return $fieldItems;
|
||||||
@ -136,8 +139,17 @@ class DatagridPresenter extends ViewableData {
|
|||||||
protected function summaryFieldsToList($summaryFields) {
|
protected function summaryFieldsToList($summaryFields) {
|
||||||
$fieldHeaders = new ArrayList();
|
$fieldHeaders = new ArrayList();
|
||||||
if (is_array($summaryFields)){
|
if (is_array($summaryFields)){
|
||||||
|
$counter = 0;
|
||||||
foreach ($summaryFields as $name=>$title){
|
foreach ($summaryFields as $name=>$title){
|
||||||
$fieldHeaders->push(new ArrayData(array('Name'=>$name, 'Title'=>$title)));
|
$arrayData = new ArrayData(array(
|
||||||
|
'Name'=>$name,
|
||||||
|
'Title'=>$title,
|
||||||
|
'IsSortable'=>true,
|
||||||
|
'IsSorted'=>false,
|
||||||
|
'SortedDirection'=>'desc')
|
||||||
|
);
|
||||||
|
$arrayData->iteratorProperties($counter++, count($summaryFields));
|
||||||
|
$fieldHeaders->push($arrayData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $fieldHeaders;
|
return $fieldHeaders;
|
||||||
@ -212,6 +224,7 @@ class DatagridPresenter_Item extends ViewableData {
|
|||||||
public function Parent() {
|
public function Parent() {
|
||||||
return $this->parent;
|
return $this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -221,7 +234,7 @@ class DatagridPresenter_Item extends ViewableData {
|
|||||||
public function Fields($xmlSafe = true) {
|
public function Fields($xmlSafe = true) {
|
||||||
$list = $this->parent->FieldList();
|
$list = $this->parent->FieldList();
|
||||||
|
|
||||||
|
$counter = 0;
|
||||||
foreach($list as $fieldName => $fieldTitle) {
|
foreach($list as $fieldName => $fieldTitle) {
|
||||||
$value = "";
|
$value = "";
|
||||||
|
|
||||||
@ -267,11 +280,13 @@ class DatagridPresenter_Item extends ViewableData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields[] = new ArrayData(array(
|
$arrayData = new ArrayData(array(
|
||||||
"Name" => $fieldName,
|
"Name" => $fieldName,
|
||||||
"Title" => $fieldTitle,
|
"Title" => $fieldTitle,
|
||||||
"Value" => $value
|
"Value" => $value
|
||||||
));
|
));
|
||||||
|
$arrayData->iteratorProperties($counter++, count($list));
|
||||||
|
$fields[] = $arrayData;
|
||||||
}
|
}
|
||||||
return new ArrayList($fields);
|
return new ArrayList($fields);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% control Headers %>
|
<% control Headers %>
|
||||||
<th class="<% if FirstLast %>ss-datagrid-{$FirstLast}<% end_if %> <% if IsSortable %>ss-datagrid-sortable<% end_if %> <% if IsSorted %>ss-datagrid-sorted ss-datagrid-{$SortedDirection}<% end_if %>">
|
<th class="<% if FirstLast %>ss-datagrid-{$FirstLast}<% end_if %><% if IsSortable %> ss-datagrid-sortable<% end_if %><% if IsSorted %> ss-datagrid-sorted ss-datagrid-{$SortedDirection}<% end_if %>">
|
||||||
$Title <span class="ui-icon"></span></th>
|
$Title <span class="ui-icon"></span></th>
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user