Created
August 9, 2012 15:46
-
-
Save stlsmiths/3305298 to your computer and use it in GitHub Desktop.
one-off extension of DataTableDataSource plugin ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need to create a one-time extension of DataTableDataSource Plugin, | |
DTDSAddPag = Y.Base.create('datasourcepag', Y.Plugin.DataTableDataSource, [], { | |
// Need to override this base method ... | |
onDataReturnInitializeTable: function(e) { | |
var records = (e.response && e.response.results) || []; | |
// Add this to update the DS state | |
this.set('state', e.response.meta ); | |
this.get("host").set("data", records); | |
} | |
},{ | |
// It's a plugin, so it needs these specified ... | |
NAME: 'datatableDataSourcePag', | |
NS: 'datasourcepag', | |
// Need two new attributes to be added ... | |
ATTRS:{ | |
queryStringTemplate : { | |
value: null | |
}, | |
state: { | |
value: { | |
startIndex: 0, | |
numRecs: 0 | |
} | |
} | |
} | |
}); | |
// Now use all this stuff ... | |
var myDS = new Y.DataSource.IO(...); | |
myDS.plug(Y.Plugin.DataSourceJSONSchema, { ... }); | |
var myDT = new Y.DataTable(...); | |
myDT.plug( DTDSAddPag, { | |
datasource: ds, | |
initialRequest: '?iopt=getdata&startIndex=0&numRecs=500', | |
queryStringTemplate: '?iopt=getdata&startIndex={startIndex}&numRecs={numRecs}' | |
}); | |
myDT.render(...); | |
myDT.datasource.load(...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment