matlabmann 2013-12-10 17:05
浏览 40
已采纳

wp_list_table放置不属于数据库的表头和表内容

I'm having hard time with this. I know WP_List_Table will generate the table for you and the get_columns will set the header and footer of the table that came from an array well in most case that came from the database.

What if I have this database table and it's fields

+----------------+
| Field |  Type  |
+-------+--------+
| id    | int    |
+-------+--------+
| name  | varchar|
+-------+--------+

Then in my get_columns function.

function get_columns() {
  $columns = array(
           'id' => 'ID',
           'name' => 'Name'
           );
  return $columns;
}

So with that.. It'll give me html table like this..

+--------------------+
| ID    |  Name      |
+-------+------------+
| 1     |  Foo       |
+-------+------------+
| 2     |  Bar       |
+-------+------------+

BUT (1) how can I add another header and footer that does not belong in the database? I would want to achieve something like this..

+--------------------+--------+
| ID    |  Name      | Option |
+-------+------------+--------+
| 1     |  Foo       | Click  |
+-------+------------+--------+
| 2     |  Bar       | Click  |
+-------+------------+--------+

(2) I would also want to wrap the Click text in a <form> so I can do some actions with it. I don't know how to deal with this. Any help would be much appreciated.

  • 写回答

1条回答 默认 最新

  • doulu1907 2013-12-10 18:14
    关注

    Add the field to your get_columns() function like this:

    function get_columns() {
      $columns = array(
               'id' => 'ID',
               'name' => 'Name',
               'cb' => '<input type="checkbox" />'
               );
      return $columns;
    }
    

    The cb column is actually a special case and it automatically creates a "select all" checkbox in your table header. Form functionality is built in so, depending on what you want to do, you'd create some actions by overwriting get_bulk_actions() function. More information on this can be found here: http://wpengineer.com/2426/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题