make table cells clickable with hyperlink callback

This commit is contained in:
Oliver Gorwits
2012-01-07 19:36:26 +00:00
parent 3aa0a56de5
commit e7860b2aea
3 changed files with 15 additions and 3 deletions

View File

@@ -35,11 +35,15 @@ ajax '/ajax/content/search/vlan' => sub {
results => $set, results => $set,
columns => [ columns => [
{ key => 'dns', label => 'Device' }, { key => 'dns', label => 'Device' },
{ key => [qw/vlan description/], label => 'Description' }, { key => 'vlan.description', label => 'Description' },
{ key => 'model', label => 'Model' }, { key => 'model', label => 'Model' },
{ key => 'os', label => 'OS' }, { key => 'os', label => 'OS' },
{ key => 'vendor', label => 'Vendor' }, { key => 'vendor', label => 'Vendor' },
], ],
hyperlink => sub {
my $row = shift;
return '/device?q=' . $row->ip;
},
}, { layout => undef }; }, { layout => undef };
}; };

View File

@@ -32,3 +32,11 @@
.nd_search { .nd_search {
margin-top: 15px; margin-top: 15px;
} }
.nd_linkcell {
text-decoration: none !important;
color: #404040;
display: block;
padding: 0px;
height: 100%;
}

View File

@@ -11,10 +11,10 @@
<tr> <tr>
[% FOREACH col IN columns %] [% FOREACH col IN columns %]
[% SET val = row %] [% SET val = row %]
[% FOREACH method IN col.key %] [% FOREACH method IN col.key.split('\.') %]
[% SET val = val.$method %] [% SET val = val.$method %]
[% END %] [% END %]
<td>[% val %]</td> <td><a class="nd_linkcell" href="[% hyperlink(row) %]">[% val %]</a></td>
[% END %] [% END %]
</tr> </tr>
[% END %] [% END %]