Skip to content

Instantly share code, notes, and snippets.

@adam704a
Created March 15, 2013 20:40
Show Gist options
  • Save adam704a/5172952 to your computer and use it in GitHub Desktop.
Save adam704a/5172952 to your computer and use it in GitHub Desktop.
Transforming data from a jqxDataAdapter
var dataAdapter = new jQuery.jqx.dataAdapter(source, {
autoBind: true,
loadComplete: function (records) {
//show the export
jQuery("#export_dropdown_list").jqxDropDownList({ width: '200px', height: '18px', theme: cp_theme });
jQuery("#export_dropdown_list").jqxDropDownList('loadFromSelect', 'exporter_source');
jQuery("#export_dropdown_list").jqxDropDownList({selectedIndex: 0});
jQuery("#exportButton").show();
},
beforeLoadComplete: function (records) {
var length = records.length;
var value = "";
for (var i = 0; i < length; i++) {
// Transform the textual data (this is one approach for internationalizing data in the reports)
records[i]['reportingPeriod'] = records[i]['reportingPeriod'] == "1st SAR (October-March)" ? "1st SAR (Oct-Mar)" : records[i]['reportingPeriod'];
records[i]['reportingPeriod'] = records[i]['reportingPeriod'] == "2nd SAR (October-September)" ? "2nd SAR (Oct-Sep)" : records[i]['reportingPeriod'];
records[i]['reportingPeriod'] = records[i]['reportingPeriod'] == "Mid-year data submission" ? "Mid-year" : records[i]['reportingPeriod'];
records[i]['workbookYear'] = records[i]['workbookYear'] == "FY12 (October 2011 - September 2012)" ? "FY12 (Oct 2011 - Sep 2012)" : records[i]['workbookYear'];
records[i]['workbookYear'] = records[i]['workbookYear'] == "FY13 (October 2012 - September 2013)" ? "FY13 (Oct 2012 - Sep 2013)" : records[i]['workbookYear'];
records[i]['workbookYear'] = records[i]['workbookYear'] == "FY14 (October 2013 - September 2014)" ? "FY14 (Oct 2013 - Sep 2013)" : records[i]['workbookYear'];
records[i]['workbookYear'] = records[i]['workbookYear'] == "FY12 (October 2011 - September 2012)" ? "FY15 (Oct 2014 - Sep 2014)" : records[i]['workbookYear'];
records[i]['workbookYear'] = records[i]['workbookYear'] == "FY12 (October 2011 - September 2012)" ? "FY16 (Oct 2015 - Sep 2015)" : records[i]['workbookYear'];
}
return records;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment