Search code examples
javascriptbackbone.jsbackgrid

Backgrid.js with Backbone


I am using Backgrid for table structure. Now, I have to add action column having edit, view, delete buttons with column Header 'Actions'. I don't get how to do it using Backgrid. As we provided one column with one cell so how can I merge more than one cell under one column. Any idea?


Solution

  • This question is a bit old, so I am not sure if you found an answer. I am doing something very similar and found that you can extend the Backgrid cell when creating your columns. Hope this helps!

    var columns = [
        {
            OTHER COLUMNS GO HERE
        },
        {
            name: 'actions',
            label: 'Actions',
            editable: false,
            sortable: false,
            cell: Backgrid.Cell.extend({
                template: _.template(" TEMPLATE OR HTML GOES HERE "),
    
                render: function () {
                    this.$el.html(this.template());
                    return this;
                }
           })
        }
    ]
    

    EDIT: I just added the sortable option, after realizing that sortable defaults to true. You probably do not want to sort on the actions column. :)