It is very handy to set an Initial View within Design Studio at design-time. Presumably, behind the scenes, the initial view is stored as some JSON string and used to initialize the Data Source. I am wondering if its possible to take advantage of this functionality from an SDK component.
While the methods on the Data Source object are functionally complete - they are a bit cumbersome when trying to make a lot of changes to a Data Source's view. I would much rather build an 'Initial View' JSON in the .ZTL and pass it directly to the Data Source to completely configure the view with a single function call.
For example I would like to set layout, filters, results display. This is the only way I know to do this now:
DS_1.setFilter("DB7VSUP6QYPP3Q0B8VD7GTCH2", ['DB7VSUP6QYQGSCC2KESTJ8QQU']);
DS_1.moveDimensionToColumns("DB7VSUP6QYPP3Q0B8VD7GTCH2");
DS_1.moveDimensionToRows("0CALMONTH");
DS_1.setTotalsDisplay("0CALMONTH", TotalsDisplay.HIDE);
I would much rather do this (my own syntax, since I do not know the format for the Initial View object):
var myview = {
layout: {
columns: ['DB7VSUP6QYPP3Q0B8VD7GTCH2'],
rows: ['0CALMONTH']
},
filters: {
DB7VSUP6QYPP3Q0B8VD7GTCH2: ['DB7VSUP6QYQGSCC2KESTJ8QQU']
},
dimensions: {
0CALMONTH: {totaldisplay: TotalsDisplay.HIDE}
}
};
DS_1.setView(JSON.stringify(myview));