Commit 636c0e5e authored by Ted Trask's avatar Ted Trask
Browse files

Modify adhocquery to use tablesorter for formatting result

parent 6a84042c
......@@ -5,31 +5,61 @@ html = require("acf.html")
<style type="text/css">
#content table { border-collapse: collapse; width: 100%; }
#content table td { white-space: normal; padding-right:20px; border-bottom:1px solid #999; }
#content table tr.mark { background: #E9E9E9; }
#content table td { white-space: normal; padding-right:20px; }
</style>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
<script type="text/javascript">
if (typeof $.tablesorter == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
}
</script>
<%
local tablesortercolumns = {}
if form.value.types then
for i,t in ipairs(form.value.types.value) do
if string.match(t, "undefined") then
tablesortercolumns[#tablesortercolumns+1] = (i-1)..":{sorter: false}"
end
end
end
%>
<script type="text/javascript">
$(function(){
$("#adhocresult").tablesorter({headers: {<%= table.concat(tablesortercolumns, ", ") %>}, widgets: ['zebra']});
});
</script>
<% if form.value.result then %>
<H1><%= html.html_escape(form.value.result.label) %></H1>
<% if #form.value.result.value == 0 then %>
<p>No results, try adjusting query</p>
<% else %>
<TABLE>
<TABLE id="adhocresult" class="tablesorter">
<THEAD>
<TR style="font-weight:bold;">
<% for i,name in ipairs(form.value.names.value) do %>
<TD class="header"><%= html.html_escape(name) %></TD>
<TH class="header"><%= html.html_escape(name) %></TH>
<% end %>
</TR>
<% for i,row in ipairs(form.value.result.value) do
local a,b = math.modf((i/2))
local mark = ''
if (b == 0) then mark=' class="mark"' end %>
<TR<%= mark %>>
</THEAD>
<TBODY>
<% for i,row in ipairs(form.value.result.value) do %>
<TR>
<% for j,name in ipairs(form.value.names.value) do %>
<TD><%= html.html_escape(row[name]) %></TD>
<% end %>
</TR>
<% end %>
<TBODY>
</TABLE>
<% if viewlibrary.check_permission("downloadadhocquery") then %>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment