ENHANCEMENT Added correct styling of sorting and odd even on grid table

This commit is contained in:
Stig Lindqvist 2011-09-30 10:59:52 +13:00
parent b1b1615a58
commit 488734e53e
2 changed files with 22 additions and 7 deletions

View File

@ -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;
@ -212,6 +224,7 @@ class DatagridPresenter_Item extends ViewableData {
public function Parent() {
return $this->parent;
}
/**
*
@ -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);
}

View File

@ -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>