Skip to content

Commit

Permalink
Added html title attribute on LinkColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeulette committed Nov 27, 2014
1 parent e5ecc13 commit 7bf16ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Expand Up @@ -5,7 +5,7 @@ CHANGES
2.0.0a2 (unreleased)
--------------------

- Nothing changed yet.
- Added html title attribute on LinkColumn


2.0.0a1 (2013-02-26)
Expand Down
9 changes: 7 additions & 2 deletions src/z3c/table/column.py
Expand Up @@ -350,6 +350,7 @@ class LinkColumn(Column):
linkTarget = None
linkContent = None
linkCSS = None
linkTitle = None

def getLinkURL(self, item):
"""Setup link url."""
Expand All @@ -361,6 +362,10 @@ def getLinkCSS(self, item):
"""Setup link css."""
return self.linkCSS and ' class="%s"' % self.linkCSS or ''

def getLinkTitle(self, item):
"""Setup link title."""
return self.linkTitle and ' title="%s"' % self.linkTitle or ''

def getLinkTarget(self, item):
"""Setup link css."""
return self.linkTarget and ' target="%s"' % self.linkTarget or ''
Expand All @@ -373,8 +378,8 @@ def getLinkContent(self, item):

def renderCell(self, item):
# setup a tag
return '<a href="%s"%s%s>%s</a>' % (self.getLinkURL(item),
self.getLinkTarget(item), self.getLinkCSS(item),
return '<a href="%s"%s%s%s>%s</a>' % (self.getLinkURL(item),
self.getLinkTarget(item), self.getLinkCSS(item), self.getLinkTitle(item),
self.getLinkContent(item))


Expand Down
11 changes: 6 additions & 5 deletions src/z3c/table/column.txt
Expand Up @@ -1052,6 +1052,7 @@ columns which can point to a page with the item as context:
... linkName = 'myLink.html'
... linkTarget = '_blank'
... linkCSS = 'myClass'
... linkTitle = 'Click'

>>> class MyLinkTable(table.Table):
... cssClassSortedOn = None
Expand Down Expand Up @@ -1082,23 +1083,23 @@ Now create, update and render our table:
</thead>
<tbody>
<tr>
<td><a href="http://127.0.0.1/container/first/myLink.html" target="_blank" class="myClass">first</a></td>
<td><a href="http://127.0.0.1/container/first/myLink.html" target="_blank" class="myClass" title="Click">first</a></td>
<td>number: 1</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/container/fourth/myLink.html" target="_blank" class="myClass">fourth</a></td>
<td><a href="http://127.0.0.1/container/fourth/myLink.html" target="_blank" class="myClass" title="Click">fourth</a></td>
<td>number: 4</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/container/second/myLink.html" target="_blank" class="myClass">second</a></td>
<td><a href="http://127.0.0.1/container/second/myLink.html" target="_blank" class="myClass" title="Click">second</a></td>
<td>number: 2</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/container/third/myLink.html" target="_blank" class="myClass">third</a></td>
<td><a href="http://127.0.0.1/container/third/myLink.html" target="_blank" class="myClass" title="Click">third</a></td>
<td>number: 3</td>
</tr>
<tr>
<td><a href="http://127.0.0.1/container/zero/myLink.html" target="_blank" class="myClass">zero</a></td>
<td><a href="http://127.0.0.1/container/zero/myLink.html" target="_blank" class="myClass" title="Click">zero</a></td>
<td>number: 0</td>
</tr>
</tbody>
Expand Down

0 comments on commit 7bf16ff

Please sign in to comment.