PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/README.md

https://github.com/rhinoman/backgrid
Markdown | 105 lines | 82 code | 23 blank | 0 comment | 0 complexity | 124bab65173641e9b815300ecaffe571 MD5 | raw file
Possible License(s): MIT
  1. # Backgrid.js
  2. [![Build Status](https://travis-ci.org/wyuenho/backgrid.png?branch=master)](https://travis-ci.org/wyuenho/backgrid)
  3. Backgrid.js is a set of components for building semantic and easily stylable
  4. data grid widgets. It offers a simple, intuitive programming interface that
  5. makes easy things easy, but hard things possible when dealing with tabular data.
  6. ## Features
  7. The goal of Backgrid.js is to produce a set of core Backbone UI elements that
  8. offer you all the basic displaying, sorting and editing functionalities you'd
  9. expect, and to create an elegant API that makes extending Backgrid.js with extra
  10. functionalities easy.
  11. ## Advantages
  12. - No Hungarian notations.
  13. - Solid foundation. Based on Backbone.js.
  14. - Semantic and easily stylable. Just style with plain CSS like you would a normal HTML table.
  15. - Low learning curve. Works with plain old Backbone models and collections. Easy things are easy, hards things possible.
  16. - Highly modular and customizable. Components are just simple Backbone View classes, customization is easy if you already know Backbone.
  17. - Lightweight. Extra features are separated into extensions, which keeps the bloat away.
  18. - Good documentation.
  19. ## Supported browsers:
  20. - Internet Explorer 8+ [[1]](#note-1)
  21. - Chrome 4+
  22. - Safari 4+
  23. - Firefox 4+
  24. ### Notes:
  25. <span id="note-1">[1]</span>: Both the desktop and mobile versions of the above browsers are supported.
  26. ## Example
  27. ```javascript
  28. var Territory = Backbone.Model.extend({});
  29. var Territories = Backbone.Collection.extend({
  30. model: Territory,
  31. url: "examples/territories.json"
  32. });
  33. var territories = new Territories();
  34. // Fetch some countries from the url
  35. territories.fetch();
  36. // Column definitions
  37. var columns = [{
  38. name: "id", // The key of the model attribute
  39. label: "ID", // The name to display in the header
  40. editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
  41. // Defines a cell type, and ID is displayed as an integer without the ',' separating 1000s.
  42. cell: Backgrid.IntegerCell.extend({
  43. orderSeparator: ''
  44. }1)
  45. }, {
  46. name: "name",
  47. label: "Name",
  48. // The cell type can be a reference of a Backgrid.Cell subclass, any Backgrid.Cell subclass instances like *id* above, or a string
  49. cell: "string" // This is converted to "StringCell" and a corresponding class in the Backgrid package namespace is looked up
  50. }, {
  51. name: "pop",
  52. label: "Population",
  53. cell: "integer" // An integer cell is a number cell that displays humanized integers
  54. }, {
  55. name: "percentage",
  56. label: "% of World Population",
  57. cell: "number" // A cell type for floating point value, defaults to have a precision 2 decimal numbers
  58. }, {
  59. name: "date",
  60. label: "Date",
  61. cell: "date",
  62. }, {
  63. name: "url",
  64. label: "URL",
  65. cell: "uri" // Renders the value in an HTML <a> element
  66. }];
  67. // Initialize a new Grid instance
  68. var grid = new Backgrid.Grid({
  69. columns: columns,
  70. collection: territories,
  71. });
  72. // Render the grid and attach the Grid's root to your HTML document
  73. $("#example-1-result").append(grid.render().el);
  74. ```
  75. # Result:
  76. Take a look [here](http://backgridjs.com/#examples).
  77. ## More Examples
  78. Are you kidding me? This is a README file. Go to the [documentation](http://backgridjs.com/
  79. "Backbone.js Documentation") to find out more :)
  80. ## License
  81. Copyright (c) 2013 Jimmy Yuen Ho Wong
  82. Licensed under the [MIT license](LICENSE-MIT "MIT License").