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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大