Estoy tratando de usar 2 formateadores de datos y me está dando un error SyntaxError: Cadena inesperada. Si estoy usando solo 1 formateador, entonces funciona bien; de lo contrario, da un error. ¿Cómo puedo usar ambos formateadores, alguna idea?
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, parece que te falta una coma entre las funciones de formateo de "comandos" y "archivo"
formateadores: {
"formateador1": función (columna, fila)
{
devuelve /* tu código aquí */;
},
"formateador2": función (columna, fila)
{
devuelve /* tu código aquí */;
},
"formateador3": función (columna, fila)
{
devuelve /* tu código aquí */;
}
}