cloudflarearchive / backgrid

Finally, an easily stylable semantic HTML data grid widget with a Javascript API that doesn't suck.
http://backgridjs.com
MIT License
2.01k stars 325 forks source link

Add classname to certain th-element #583

Closed crebuh closed 8 years ago

crebuh commented 9 years ago

Is there a possibility to add a certain classname (e.g. hidden-xs) to a certain th element.

For example I've defined a column schema like

{
            name: 'billingdate', // The key of the model attribute
            label: 'Billingdate', // The name to display in the header
            editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
            classname: 'hidden-xs'
            cell: 'string'
}

now the hidden-xs class is added to all of these tds in my grid. But what could i do to add the classname also to the th above those tds?

A workaround would be to work with the css, because to each th the name of the attribute is also added as classname (in this example billingdate). It would also work, but would need much more custom css styles.

luishdez commented 9 years ago

You can extend the header cell

  {
    name: "field",
    headerCell: Backgrid.HeaderCell.extend({
      tagName: 'th class="width"'
    }),
    cell: 'integer'
  },

UPDATE: This is no longer valid in backbone … the example below is the correct way.

wyuenho commented 8 years ago
{
    name: "field",
    headerCell: Backgrid.HeaderCell.extend({
        className: 'whatever you want'
    }),
    cell: 'integer'
  },