Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Apr 23, 2012
2 parents 2141bee + e282944 commit 8b10269
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
10 changes: 5 additions & 5 deletions index.html
Expand Up @@ -103,7 +103,7 @@ <h1>Pivot.js</h1>
<ul class="dropdown-menu">
<li><a id="ar-aged-balance" href="#">AR Aged Balance</a></li>
<li><a id="acme-detail-report" href="#">Acme Corp Detail</a></li>
<li><a id="jacksonville-invoice-detail" href="#">Jacksonville Invoice Detail</a></li>
<li><a id="miami-invoice-detail" href="#">Miami Invoice Detail</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -198,15 +198,15 @@ <h1>Results</h1>

// **Sexy** In your console type pivot.config() to view your current internal structure (the full initialize object). Pass it to setup and you have a canned report.
$('#ar-aged-balance').click(function(event){
setupPivot({"url":'./lib/csv/demo.csv', "fields": fields, "filters":{},"rowLabels":["employer"],"columnLabels":["age_bucket"],"summaries":["balance"]})
$('#pivot-demo').pivot_display('reprocess_display', {rowLabels:["employer"], columnLabels:["age_bucket"], summaries:["balance"]})
});

$('#acme-detail-report').click(function(event){
setupPivot({"url":'./lib/csv/demo.csv', "fields": fields, "filters":{"employer":"Acme Corp"},"rowLabels":["city","last_name","first_name","state","invoice_date"],"columnLabels":[],"summaries":[]})
$('#pivot-demo').pivot_display('reprocess_display', {filters:{"employer":"Acme Corp"},rowLabels:["city","last_name","first_name","state","invoice_date"]})
});

$('#jacksonville-invoice-detail').click(function(event){
setupPivot({"url":'./lib/csv/demo.csv', "fields": fields, "filters":{"city":"Jacksonville"},"rowLabels":["last_name","first_name","employer","invoice_date"],"columnLabels":[],"summaries":["payment_amount"]})
$('#miami-invoice-detail').click(function(event){
$('#pivot-demo').pivot_display('reprocess_display', {"filters":{"city":"Miami"},"rowLabels":["last_name","first_name","employer","invoice_date"],"summaries":["payment_amount"]})
});
});
</script>
26 changes: 21 additions & 5 deletions jquery_pivot.js
Expand Up @@ -28,11 +28,7 @@ var methods = {

if (options.skipBuildContainers === undefined || options.skipBuildContainers === false) self.build_containers();

self.build_toggle_fields('#row-label-fields', pivot.fields().rowLabelable, 'row-labelable');
self.build_toggle_fields('#column-label-fields', pivot.fields().columnLabelable, 'column-labelable');
self.build_toggle_fields('#summary-fields', pivot.fields().summarizable, 'summary');

methods.build_filter_list();
self.populate_containers();

$('.row-labelable').change(function(event) {
self.update_label_fields('row');
Expand Down Expand Up @@ -75,6 +71,26 @@ var methods = {
}
});
},
populate_containers: function(){
methods.build_toggle_fields('#row-label-fields', pivot.fields().rowLabelable, 'row-labelable');
methods.build_toggle_fields('#column-label-fields', pivot.fields().columnLabelable, 'column-labelable');
methods.build_toggle_fields('#summary-fields', pivot.fields().summarizable, 'summary');
methods.build_filter_list();
},
reprocess_display : function(options){
if (options.rowLabels === undefined) options.rowLabels = [];
if (options.columnLabels === undefined) options.columnLabels = [];
if (options.summaries === undefined) options.summaries = [];
if (options.filters === undefined) options.filters = {};

pivot.filters().set(options.filters);
pivot.display().summaries().set(options.summaries);
pivot.display().rowLabels().set(options.rowLabels);
pivot.display().columnLabels().set(options.columnLabels);

methods.populate_containers();
methods.update_results();
},
build_containers : function(){

var containers = '<div style="margin-left:-20px;*zoom:1;">' +
Expand Down

0 comments on commit 8b10269

Please sign in to comment.