【问题标题】:How to make the buttons in one column using JavaScript?如何使用 JavaScript 在一列中制作按钮?
【发布时间】:2020-02-24 08:05:27
【问题描述】:
 "columns": [
            { "data": "Id", "name": "Id", "autoWidth": true },
            { "data": "Code", "name": "Code", "autoWidth": true },
            { "data": "Name", "name": "Name", "autoWidth": true },
            {
                "orderable": false,
                "searchable": false,
                "render": function (data, type, full, meta) { return '<a class="btn btn-primary btn-group" href="/Grades/' + full.Id + '">Details</a>'; },
            },
            {
                "orderable": false,
                "searchable": false,
                "render": function (data, type, full, meta) { return '<a class="btn btn-secondary btn-group" href="/Grades/' + full.Id + '/Edit/">Edit</a>'; },
            },
            {
                "orderable": false,
                "searchable": false,
                "render": function (data, type, full, meta) { return '<a class="btn btn-danger btn-group" href="/Grades/' + full.Id + '/Delete/">Delete</a>'; }
            }
        ]

目前我正在使用上面的代码,并且视图就像图像中的一样。 [任何建议!!!]

[Image1]

【问题讨论】:

    标签: javascript html css asp.net asp.net-core


    【解决方案1】:

    只需在一列中返回它们

    "columns": [
            { "data": "Id", "name": "Id", "autoWidth": true },
            { "data": "Code", "name": "Code", "autoWidth": true },
            { "data": "Name", "name": "Name", "autoWidth": true },
            {
                "orderable": false,
                "searchable": false,
                "render": function (data, type, full, meta) {
                    return '<a class="btn btn-primary btn-group" href="/Grades/' + full.Id + '">Details</a>'
                        + '<a class="btn btn-secondary btn-group" href="/Grades/' + full.Id + '/Edit/">Edit</a>'
                        +'<a class="btn btn-danger btn-group" href="/Grades/' + full.Id + '/Delete/">Delete</a>' ;
                }
            }
    ]
    

    【讨论】:

    • 这是完美的。 (+) 需要换行。非常感谢
    • @RomeoJ 太好了,如果你解决了问题,你能accept the answer吗?
    • @Xing Zou ,然后只有我可以得到确认,代码工作正常。无论如何,谢谢。
    猜你喜欢
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2020-12-10
    相关资源
    最近更新 更多