├── README.md ├── css └── parse-table.css ├── images ├── del.png ├── sort_asc.png ├── sort_both.png ├── sort_desc.png └── spinny.gif ├── index.html ├── js └── ParseTable.js └── license.txt /README.md: -------------------------------------------------------------------------------- 1 | Parse.com Ajax Datatable 2 | ======================== 3 | 4 | This is a simple flexible library that allows you to view and edit your parse.com 5 | data in a tabular format. You can set the table to be editable and/or deletable. 6 | For basic types the editing is very simple, you just click on the field and a little 7 | editor appears. For complex types and for large amounts of data in a single cell 8 | there are interceptor functions that allow you to handle the display of the data and 9 | the method for updating, e.g. for Date types you might intercept the up event and 10 | provide your favorite Datepicker. Here is a quick run down of the features: 11 | 12 | * pagable and sortable tabular interface 13 | * interceptor design pattern for adding custom display and update features 14 | * only 200 lines of code 15 | * relies on jquery, underscore, underscore templates and of course parse 16 | 17 | 18 |  19 | 20 | This is the basic usage: 21 |
22 | pt = new ParseTable({ 23 | el : $("#table"), // where to place on the page (fills space) 24 | parseObjName : "NAME_OF_TABLE", 25 | deletable : true, // defaults to false (allows deleting if true) 26 | editable : true, // defaults to false (allows editing if true) 27 | ... 28 |29 | 30 | By default it will inspect the table and present all of the columns for display and editing. You can enforce order or omit columns using: 31 | 32 |
33 | ... 34 | cols : ['Street','City','State','PostalCode','Country'], 35 |36 | 37 | What is really powerful is the interceptors which allow you to customize the way the data is displayed and the method and UI for editing the data. For instance you may want to shorten long text entries so as not to distort the table: 38 | 39 |
40 | ... 41 | displayInterceptors:{ 42 | SOME_LONG_COLUMN : function(d){ 43 | return d.substring(0,20)+"..." 44 | } 45 | }, 46 | 47 |48 | 49 | Or present a drop down list for some other enumerated column: 50 | 51 |
52 | ... 53 | editInterceptors:{ 54 | State : function(obj){ 55 | var target = obj.el; // DOM ref to the cell 56 | var parseObj = obj.parseObj; // parse instance 57 | var col = obj.col; // column name in question 58 | var val = target.data("rawdata"); // raw data (diff if was displayIntercepted) 59 | var myEdit = $("<select class='pt_edit'><option>CA<option>NY<option>VT</select>") 60 | .val(target.html().trim()).change(function(){ 61 | parseObj.set(obj.col,$(this).val()) 62 | parseObj.save() 63 | pt.editing=false 64 | pt.render() 65 | }) 66 | target.append(myEdit) 67 | } 68 | } 69 | 70 |71 | 72 | ### Authors and Contributors 73 | @brenthamby 74 | ### Support or Contact 75 | Having trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out. -------------------------------------------------------------------------------- /css/parse-table.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | *{ 4 | font-size:12px; 5 | font-family: arial; 6 | margin: 0; 7 | padding:0; 8 | text-shadow:1px 1px 1px #fff; 9 | color:#333; 10 | } 11 | p{ 12 | padding:20px; 13 | } 14 | ul{ 15 | padding:0px 40px 0 80px; 16 | } 17 | p, ul li{ 18 | font-size:17px; 19 | } 20 | h1{ 21 | font-size:23px; 22 | padding:20px; 23 | } 24 | body{ 25 | margin:20px 150px 0 150px; 26 | } 27 | .pt_container{ 28 | position: relative; 29 | min-width:100px; 30 | padding:14px; 31 | border:1px solid #ddd; 32 | } 33 | .pt_container .pt_controls{ 34 | position: relative; 35 | float: right; 36 | clear: both; 37 | margin:4px; 38 | } 39 | .pt_container .odd { 40 | background: #FAFAFB; 41 | } 42 | .pt_container .even{ 43 | background: #eeeeee; 44 | } 45 | .pt_container .pt_header{ 46 | background-image:url('../images/sort_both.png'); 47 | background-repeat:no-repeat; 48 | background-position:center right; 49 | } 50 | .pt_container .pt_ascending { 51 | background-image:url('../images/sort_asc.png'); 52 | background-repeat:no-repeat; 53 | background-position:center right; 54 | } 55 | .pt_container .pt_descending { 56 | background-image:url('../images/sort_desc.png'); 57 | background-repeat:no-repeat; 58 | background-position:center right; 59 | } 60 | 61 | .pt_container .top_row { 62 | 63 | background-image: linear-gradient(bottom, rgb(221,221,221) 25%, rgb(187,187,187) 50%, rgb(221,221,221) 75%); 64 | background-image: -o-linear-gradient(bottom, rgb(221,221,221) 25%, rgb(187,187,187) 50%, rgb(221,221,221) 75%); 65 | background-image: -moz-linear-gradient(bottom, rgb(221,221,221) 25%, rgb(187,187,187) 50%, rgb(221,221,221) 75%); 66 | background-image: -webkit-linear-gradient(bottom, rgb(221,221,221) 25%, rgb(187,187,187) 50%, rgb(221,221,221) 75%); 67 | background-image: -ms-linear-gradient(bottom, rgb(221,221,221) 25%, rgb(187,187,187) 50%, rgb(221,221,221) 75%); 68 | background-image: -webkit-gradient( 69 | linear, 70 | left bottom, 71 | left top, 72 | color-stop(0.25, rgb(221,221,221)), 73 | color-stop(0.5, rgb(187,187,187)), 74 | color-stop(0.75, rgb(221,221,221)) 75 | ); 76 | } 77 | 78 | .pt_container button{ 79 | padding:4px; 80 | font-size: 10px; 81 | font-weight:bold; 82 | } 83 | .pt_container table{ 84 | border-spacing: 0; 85 | border:2px solid #aaa; 86 | } 87 | .pt_container th, td{ 88 | border:0; 89 | border-right:2px solid #aaa; 90 | margin: 0; 91 | padding:8px; 92 | text-align: left; 93 | position: relative; 94 | } 95 | .pt_cell{ 96 | position: relative; 97 | display: block; 98 | } 99 | .pt_container table{ 100 | width:100%; 101 | } 102 | .pt_edit{ 103 | position:absolute; 104 | z-index:2; 105 | display:block; 106 | top:-5px; 107 | left:-5px; 108 | min-width: 200px; 109 | border:3px solid #bbb; 110 | background: #ddd; 111 | padding:4px; 112 | box-shadow: 5px 5px 5px #444; 113 | } 114 | .pt_edit textarea{ 115 | width:100%; 116 | } -------------------------------------------------------------------------------- /images/del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brenthamby/parse-javascript-datatable/a9391e78e4fcc23ce07c4eb1ab8f28e7dd41b7e9/images/del.png -------------------------------------------------------------------------------- /images/sort_asc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brenthamby/parse-javascript-datatable/a9391e78e4fcc23ce07c4eb1ab8f28e7dd41b7e9/images/sort_asc.png -------------------------------------------------------------------------------- /images/sort_both.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brenthamby/parse-javascript-datatable/a9391e78e4fcc23ce07c4eb1ab8f28e7dd41b7e9/images/sort_both.png -------------------------------------------------------------------------------- /images/sort_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brenthamby/parse-javascript-datatable/a9391e78e4fcc23ce07c4eb1ab8f28e7dd41b7e9/images/sort_desc.png -------------------------------------------------------------------------------- /images/spinny.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brenthamby/parse-javascript-datatable/a9391e78e4fcc23ce07c4eb1ab8f28e7dd41b7e9/images/spinny.gif -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 67 | 68 | 69 | 70 | 71 |
75 | This is a simple flexible library that allows you to view and edit your parse.com 76 | data in a tabular format. You can set the table to be editable and/or deletable. 77 | For basic types the editing is very simple, you just click on the field and a little 78 | editor appears. For complex types and for large amounts of data in a single cell 79 | there are interceptor functions that allow you to handle the display of the data and 80 | the method for updating, e.g. for Date types you might intercept the up event and 81 | provide your favorite Datepicker. Here is a quick run down of the features: 82 |