0

I am trying to use 2 data formatters and it's giving me a error SyntaxError: Unexpected string. If I am using only 1 formatter then it's working fine otherwise it's giving a error.How can I use both the formatters any 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>
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40

1 Answers1

0

Nikhil, You appear to be missing a comma between "commands" & "file" formatter functions

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 */;
    }
}
bcadiz
  • 1