Page 1 of 1

custom function view in js viewer

Posted: Sat Jan 12, 2019 12:59 pm
by mmnp
my desired custom function work and showed result in designer preview but not shown result in browser
whats wrong

Re: custom function view in js viewer

Posted: Sun Jan 13, 2019 4:34 am
by Andrew
Hello,

Please elaborate your request?

Thank you.

Re: custom function view in js viewer

Posted: Wed Jan 16, 2019 8:57 am
by mmnp
thank you for reply

I have 2 function in my report file one of them is built in function and another is my custom function I can see the out put of both function in preview page of my designer but when i want use the report in php js viewer, built in function shown but my custom function not shown
you can find my files in attachments

thanks in advance.

Re: custom function view in js viewer

Posted: Thu Jan 17, 2019 11:29 am
by Lech Kulikowski
Hello,

Your function is added on the Code tab. In the PHP, JS version, code in events and Code tab is not supported.
You can add own function only from code:
https://stimulsoft.zendesk.com/hc/en-us ... JavaScript

Thank you.

Re: custom function view in js viewer

Posted: Sat Feb 16, 2019 5:55 am
by mmnp
Lech Kulikowski wrote: Thu Jan 17, 2019 11:29 am Hello,

Your function is added on the Code tab. In the PHP, JS version, code in events and Code tab is not supported.
You can add own function only from code:
https://stimulsoft.zendesk.com/hc/en-us ... JavaScript

Thank you.
Dear lech kulikowski
thanks for your reply as I'm new in stimulsoft may I ask please give me a sample of using my own function in the php, js version.
I could not understand from the link that you send.
thanks in advance

Re: custom function view in js viewer

Posted: Mon Feb 18, 2019 9:13 am
by Lech Kulikowski
Hello,

You should add your function in your web project code. Samples for JS, PHP you can find at the following link:
https://github.com/stimulsoft/Samples-JS-PHP

Thank you.

Re: custom function view in js viewer

Posted: Mon Jun 10, 2019 4:08 pm
by gegar
Hello

My solution is:

The function is for example:

The file function.js or save your function in this file.

var function1 = function (checklist, state) {
var result = "9867";

return result;
}

var function2 = function (sender, value) {
if (value == 'S') {
greeting = "Good morning";
} else if (value == 'N') {
greeting = "Good day";
} else {
greeting = "Good evening";
}
return greeting;
}

Stimulsoft.Report.Dictionary.StiFunctions.addFunction("Test", "Test", "checklistFunction", "", "", String, "", [String, String], [""], [""], function1);
Stimulsoft.Report.Dictionary.StiFunctions.addFunction("Test", "Test", "checklistFunctionDrill", "", "", String, "", [Stimulsoft.Report.Components.StiText, String], [""], [""], function2);
Stimulsoft.Report
.Dictionary
.StiFunctions
.addFunction('Test', 'Test', 'TestFunc', 'Function', Stimulsoft.System.Int32, Stimulsoft.System.Int32,
'Function',[Stimulsoft.System.Int32], ['i'], [''],function(i){
return 123;
});

In the files designer.php and viewer.php add the next code after report.loadFile.

</script>
<script src="Y-functions.js" type="text/javascript"></script>
<script type="text/javascript">

That is all.

Re: custom function view in js viewer

Posted: Mon Jun 10, 2019 9:31 pm
by Lech Kulikowski
Hello,

Thank you for the provided solution.