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
|
||||
*/
|
||||
function Items() {
|
||||
public function Items() {
|
||||
$fieldItems = new ArrayList();
|
||||
if($items = $this->datagrid->datasource) {
|
||||
if($items = $this->getDatagrid()->getDatasource()) {
|
||||
$counter = 0;
|
||||
foreach($items as $item) {
|
||||
if(!$item) {
|
||||
continue;
|
||||
}
|
||||
$fieldItems->push(new $this->itemClass($item, $this));
|
||||
$datagridPresenterItem = new $this->itemClass($item, $this);
|
||||
$datagridPresenterItem->iteratorProperties($counter++, $items->count());
|
||||
$fieldItems->push($datagridPresenterItem);
|
||||
}
|
||||
}
|
||||
return $fieldItems;
|
||||
@ -136,8 +139,17 @@ class DatagridPresenter extends ViewableData {
|
||||
protected function summaryFieldsToList($summaryFields) {
|
||||
$fieldHeaders = new ArrayList();
|
||||
if (is_array($summaryFields)){
|
||||
$counter = 0;
|
||||
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;
|
||||
@ -213,6 +225,7 @@ class DatagridPresenter_Item extends ViewableData {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bool $xmlSafe
|
||||
@ -221,7 +234,7 @@ class DatagridPresenter_Item extends ViewableData {
|
||||
public function Fields($xmlSafe = true) {
|
||||
$list = $this->parent->FieldList();
|
||||
|
||||
|
||||
$counter = 0;
|
||||
foreach($list as $fieldName => $fieldTitle) {
|
||||
$value = "";
|
||||
|
||||
@ -267,11 +280,13 @@ class DatagridPresenter_Item extends ViewableData {
|
||||
}
|
||||
}
|
||||
|
||||
$fields[] = new ArrayData(array(
|
||||
$arrayData = new ArrayData(array(
|
||||
"Name" => $fieldName,
|
||||
"Title" => $fieldTitle,
|
||||
"Value" => $value
|
||||
));
|
||||
$arrayData->iteratorProperties($counter++, count($list));
|
||||
$fields[] = $arrayData;
|
||||
}
|
||||
return new ArrayList($fields);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<% 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>
|
||||
<% end_control %>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user