在查看数据表显示与编辑的可能性/加元 [英] Display datatable at view with possibility of edit/add elements

查看:100
本文介绍了在查看数据表显示与编辑的可能性/加元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示在视图的DataTable与编辑的可能性/添加元素?

How can I display a datatable at view with possibility of edit/add elements?

我通过数据表对象查看,并且需要code,可以在页面中显示该表与edit_add元素的可能性

I pass Datatable object to View, and a need code that can display that table at page, with possibility of edit_add elements

推荐答案

您可以使用Jquery Bootgrid( HTTP做://www.jquery-bootgrid.com/

You can do it using Jquery Bootgrid (http://www.jquery-bootgrid.com/)

可以说,数据表有两列。

Lets say, datatable has two column.

下面是查看:

<table id="grid-basic">
    <thead>
        <tr>
            <th data-column-id="id">
                Header1
            </th>
            <th data-column-id="name">
                Header2
            </th>
            <th data-column-id="link" data-formatter="link" data-sortable="false">Header3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
           <td>
              Value1
           </td>
           <td>
               Value2
           </td>
           <td></td> // Make it empty to display option (Edit, Delete)
         </tr>
    </tbody>
</table>

下面是JavaScript:

Here is the javascript:

<script>
        $("#grid-basic").bootgrid({
            formatters: {
                "link": function (column, row) {
                    //var rowId = row.id.trim();
                    return "<a href=\"yourUrlForEdit\"><button value=\"Edit\"></button></a> <a href=\"YourUrlForDelete\"><button value=\"Delete\"></button></a>";
                }
            }
        });
    </script>

这篇关于在查看数据表显示与编辑的可能性/加元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆