Hi all
I’m newbie to SDK so I kindly ask your help for passing a value into Design Studio from a SDK component.
I mean, I want the user to use a function like:
getRows(DS_1);
And I will pass the number of rows within the Datasource (DS_1) thru an SDK custom component.
So to start, with SDK within eclipse and I’ve done so far the following simple code - extracted some pieces from this post:
http://scn.sap.com/thread/3590837
a) Contribution.xml
1. <sdkExtension
2. xmlns="http://www.sap.com/bi/zen/sdk"
3. id="com.sap.sample.simplecrosstab"
4. title="Design Studio SDK Extension Sample Simple Crosstab"
5. version="14.2"
6. vendor="SAP">
7. <component
8. id="SimpleCrosstab"
9. title="Simple Crosstab"
10. icon="res/icon.png"
11. handlerType="div"
12. databound="true">
13. <jsInclude>res/js/component.js</jsInclude>
14. <property
15. id="data"
16. title="Data Selection"
17. type="ResultSet"
18. group="DataBinding">
19. </property>
20. <propertytype="String"title="Execute"id="execute"visible="false"/>
21. <initialization>
22. <defaultValueproperty="WIDTH">150</defaultValue>
23. <defaultValueproperty="HEIGHT">200</defaultValue>
24. </initialization>
25. </component>
26. </sdkExtension>
b) Contribution.ztl
1) class com.sap.sample.simplecrosstab.SimpleCrosstab extends Component {
2) /**
Execute some method
3) */
4) String someMethod( String someParameter){*
5) //APPLICATION.alert("I am 'someMethod'. You passed me value:::: " + someParameter);
6) return this.execute = "someMethod|" + someParameter;
7) *}
c) Component.js
1. sap.designstudio.sdk.Component.subclass("com.sap.sample.simplecrosstab.SimpleCrosstab", function() {
2.
3.
4. this.afterUpdate = function() {
5. this.execute;
6. };
7.
8. this.execute = function(s){
9. var cmd = "";
10.
11. if(s!==undefined&& s.length > 1){
12. alert("Execute value: " + s);
13. return this;
14. }
15. else {
16. return this;
17. }
18. };
19.
20. });
Afterwards in DS I have:
TEXT_1.setText(""+SIMPLECROSSTAB_1.someMethod(INPUTFIELD_1.getValue()));
And it returns in DS:
As expected.
However if I change the JS code to add:
1. this.execute = function(s){
2. var cmd = "";
3.
4. if(s!==undefined&& s.length > 1){
5. alert("Execute value: " + s);
this.s = "12345 ";
returnthis;
7. }
8. else {
9. return this;
10. }
11.};
The return to DS is not changed to “12345”.
How can I achieve this?
I just to want, in the above example, the user to receive in DS:
var X = getRows(DS_1);
and X is equal to “12345”.
My final goal is , by using the “com.sap.sample.simplecrosstab”, to loop into the data and return the number of rows.
…
function applyData() {
var OFFSET_COLS = numRowTuples;
var OFFSET_ROWS = numColTuples;
var dataIndex = 0;
for (var row = 0; row < numRowsOfData; row++) {
for (var col = 0; col < numColsOfData; col++) {
arrColspan[OFFSET_COLS + col][OFFSET_ROWS + row] = 1;
arrRowspan[OFFSET_COLS + col][OFFSET_ROWS + row] = 1;
arrText[OFFSET_COLS + col][OFFSET_ROWS + row] = data.formattedData[dataIndex];
arrType[OFFSET_COLS + col][OFFSET_ROWS + row] = computeTypeOfData(col, row);
arrDataAttributes[OFFSET_COLS + col][OFFSET_ROWS + row] = computeDataAttributes(data.tuples[dataIndex]);
dataIndex++;
}
number_of_rows++;
}
}
…
“number_of_rows" --> Is in fact what I need to return.
Appreciate your help and assistance.
Thanks in advance.
Armando Santos