2510 Posts in 675 Topics by 520 members
Data Model Questions
SilverStripe Forums » Data Model Questions » renaming columntitles of listview in modeladmin
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1145 Views |
-
renaming columntitles of listview in modeladmin

6 January 2010 at 4:47am
hi,
I'm wondering if it is possible to rename the columntitles of the resultslist in modeladmin.
that would be usefull if the data are retrieved in a more complex way. For exampe:
static $summary_fields = array(
'MyData.Data'
);
will echo the following columntitle: "My Data Data", while just "Data" would do fine (and be less ugly ;-) ).I tried the following (a parallel with $searchable_fields):
static $summary_fields = array(
'MyData.Data'=>array('title'=>'Data')
);
But that throws an error. Does someone know a solution? -
Re: renaming columntitles of listview in modeladmin

6 January 2010 at 9:31am
I'm pretty sure you can just do the title as the array value
static $summary_fields = array(
'MyData.Data' => 'Data Column'
); -
Re: renaming columntitles of listview in modeladmin

7 January 2010 at 9:33am
Hi Willr,
Thanks for your reply. At first I slammed my head: so simple a solution, it just has to be true...
But unfortunately, it doesn't work: either the column disappears (in case of 'MyData.Data' => 'Data Column') as a whole, or only the data in the column disappear (in case of renaming the column: 'Data'=>'Data Column').
Maybe someone has another idea?
-
Re: renaming columntitles of listview in modeladmin

6 March 2010 at 12:40pm
sometimes it works and sometimes it doesn't. I can't get it to work consistently with the simple example that Will gave. Has anyone else tried to rename the columns of the grid in the ModelAdmin?
Maybe this is a good place to implement the DOM plugin since it's so much more robust?
-
Re: renaming columntitles of listview in modeladmin

6 March 2010 at 12:52pm
ACTUALLY...i just found the answer to this. the more i learn about SS the more i fall in love with it!!!
After you have defined your $summary_fields:
static $summary_fields = array(
'ListingType.ListingType',
'PropertyType.PropertyType',
'Name',
'Address',
'City',
'State.StateName',
'ZipCode',
);You can/need to the define the labels:
static $field_labels = array(
'ListingType.ListingType' => 'Listing Type',
'PropertyType.PropertyType' => 'Property Type',
'State.StateName' => 'State',
);I like this method...because it keeps everything in your model settings. very nice, though i also agree that it should have simply worked in the example Will gave. that would have been even better.
-
Re: renaming columntitles of listview in modeladmin

4 April 2010 at 5:56am
Nice.
$field_labels is a cleaner way of defining the labels, rather than doing it 'inline'. It means the labels are unified wherever you display them e.g. in $search_fields and in $summary_fields. No need to define them more than once.
| 1145 Views | ||
|
Page:
1
|
Go to Top |




