duancong6937 2013-12-23 19:44
浏览 55
已采纳

如何使Joomla Table可排序?

I have added following PHP code in my Joomla webapplication. This will create a table of all users from a User Group.

How Can I make this table sortable?

Is there some Joomla/PHP code or plugin to order this list by Name? Can I add a parameter to sort this by any column?

<?php
$teachers = JAccess::getUsersByGroup(10); //change number in the brackets

echo "<table class=\"table table-striped\">";
echo "<thead>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Street</th>";
echo "<th>Zip</th>";
echo "<th>City</th>";
echo "<th>Phone</th>";
echo "<th>Email</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
foreach($teachers as $user_id) {
    $user = JFactory::getUser($user_id);
    $profile = JUserHelper::getProfile($user->id);
    echo "<tr>";
    echo "<td>".$user->name."</td>";
    echo "<td>".$profile->profile['address1']."</td>";
    echo "<td>".$profile->profile['postal_code']."</td>";
    echo "<td>".$profile->profile['city']."</td>";
    echo "<td>".$profile->profile['phone']."</td>";
    echo "<td>".$user->email."</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
  • 写回答

4条回答 默认 最新

  • dongyuan1870 2013-12-23 19:45
    关注

    I think the easiest way would be to use jquery or use a jquery plugin. You can use DataTables or Tablesorter, they are jquery plugins that would put that feature.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料