簡體   English   中英

如何在 jquery 引導網格中使用 2 個格式化程序?

[英]How to use 2 formatters in jquery bootgrid?

我正在嘗試使用 2 個數據格式化程序,它給我一個錯誤 SyntaxError: Unexpected string。 如果我只使用 1 個格式化程序,那么它工作正常,否則會出錯。我怎么能同時使用這兩個格式化程序呢?

 var grid = $("#product_grid").bootgrid({ ajax: true, rowSelect: true, post: function () { /* To accumulate custom parameter with the request object */ return { id: "b0df282a-0d67-40e5-8558-c9e93b7befed" }; }, url: "response.php", formatters: { "commands": function(column, row) { return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " + "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>"; } "file": function(column,row) { return "<img src=\"img/" + row.file + "\" width=50px/>"; } }
 <table id="product_grid" class="table table-condensed table-hover table-striped" width="60%" cellspacing="0" data-toggle="bootgrid"> <thead> <tr> <th data-column-id="id" data-type="numeric" data-identifier="true">Product ID</th> <th data-column-id="p_name">Product</th> <th data-column-id="mrp">MRP</th> <th data-column-id="selling_price">Selling Price</th> <th data-column-id="category">Category</th> <th data-column-id="description">Description</th> <th data-column-id="file" data-formatter="file" data-sortable="false">Image</th> <th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th> </tr> </thead> </table>

Nikhil,您似乎在“命令”和“文件”格式化程序函數之間缺少逗號

formatters: {
    "formatter1": function(column, row)
    {
        return /* your code here */;
    },
    "formatter2": function(column, row)
    {
        return /* your code here */;
    },
    "formatter3": function(column, row)
    {
        return /* your code here */;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM