PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/README.md

https://github.com/TechnotronicOz/backgrid
Markdown | 114 lines | 89 code | 25 blank | 0 comment | 0 complexity | 57229535d831f4237e25229422704d28 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. - Well tested. Comes with [100s of test cases](http://wyuenho.github.io/backgrid/test/).
  20. ## Supported browsers [[1]](#note-1):
  21. - Internet Explorer 8 [[2]](#note-2)
  22. - Internet Exploror 9+
  23. - Chrome 4+
  24. - Safari 4+
  25. - Firefox 4+
  26. - Opera 9+
  27. ### Notes:
  28. - <span id="note-1">[1]</span>: Both the desktop and mobile versions of the above browsers are supported.
  29. - <span id="note-2">[2]</span>: With the exception of the Filter extension's search icon CSS.
  30. ## Example
  31. ```javascript
  32. var Territory = Backbone.Model.extend({});
  33. var Territories = Backbone.Collection.extend({
  34. model: Territory,
  35. url: "examples/territories.json"
  36. });
  37. var territories = new Territories();
  38. // Fetch some countries from the url
  39. territories.fetch();
  40. // Column definitions
  41. var columns = [{
  42. name: "id", // The key of the model attribute
  43. label: "ID", // The name to display in the header
  44. editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
  45. // Defines a cell type, and ID is displayed as an integer without the ',' separating 1000s.
  46. cell: Backgrid.IntegerCell.extend({
  47. orderSeparator: ''
  48. })
  49. }, {
  50. name: "name",
  51. label: "Name",
  52. // The cell type can be a reference of a Backgrid.Cell subclass, any Backgrid.Cell subclass instances like *id* above, or a string
  53. cell: "string" // This is converted to "StringCell" and a corresponding class in the Backgrid package namespace is looked up
  54. }, {
  55. name: "pop",
  56. label: "Population",
  57. cell: "integer" // An integer cell is a number cell that displays humanized integers
  58. }, {
  59. name: "percentage",
  60. label: "% of World Population",
  61. cell: "number" // A cell type for floating point value, defaults to have a precision 2 decimal numbers
  62. }, {
  63. name: "date",
  64. label: "Date",
  65. cell: "date",
  66. }, {
  67. name: "url",
  68. label: "URL",
  69. cell: "uri" // Renders the value in an HTML <a> element
  70. }];
  71. // Initialize a new Grid instance
  72. var grid = new Backgrid.Grid({
  73. columns: columns,
  74. collection: territories,
  75. });
  76. // Render the grid and attach the Grid's root to your HTML document
  77. $("#example-1-result").append(grid.render().el);
  78. ```
  79. # Result:
  80. Take a look [here](http://backgridjs.com/index.html#basic-example).
  81. ## More Examples
  82. Are you kidding me? This is a README file. Go to the [documentation](http://backgridjs.com/
  83. "Backbone.js Documentation") to find out more :)
  84. ## Commercial Support
  85. If there's a feature that you would like me to implement or a bug you'd like me
  86. to fix, you can contact me at this [email address](mailto:wyuenho@gmail.com).
  87. ## License
  88. Copyright (c) 2013 Jimmy Yuen Ho Wong
  89. Licensed under the [MIT license](LICENSE-MIT "MIT License").