custom function view in js viewer

Stimulsoft Reports.PHP discussion
Post Reply
mmnp
Posts: 3
Joined: Sat Jan 12, 2019 12:55 pm

custom function view in js viewer

Post by mmnp » Sat Jan 12, 2019 12:59 pm

my desired custom function work and showed result in designer preview but not shown result in browser
whats wrong
Andrew
Posts: 3827
Joined: Fri Jun 09, 2006 3:58 am

Re: custom function view in js viewer

Post by Andrew » Sun Jan 13, 2019 4:34 am

Hello,

Please elaborate your request?

Thank you.
mmnp
Posts: 3
Joined: Sat Jan 12, 2019 12:55 pm

Re: custom function view in js viewer

Post by mmnp » Wed Jan 16, 2019 8:57 am

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.
Attachments
2.jpg
2.jpg (64.92 KiB) Viewed 559 times
1.jpg
1.jpg (59.38 KiB) Viewed 559 times
report.zip
(1.79 MiB) Downloaded 25 times
Lech Kulikowski
Posts: 1637
Joined: Tue Mar 20, 2018 5:34 am

Re: custom function view in js viewer

Post by Lech Kulikowski » 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.
mmnp
Posts: 3
Joined: Sat Jan 12, 2019 12:55 pm

Re: custom function view in js viewer

Post by mmnp » Sat Feb 16, 2019 5:55 am

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
Lech Kulikowski
Posts: 1637
Joined: Tue Mar 20, 2018 5:34 am

Re: custom function view in js viewer

Post by Lech Kulikowski » Mon Feb 18, 2019 9:13 am

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.
gegar
Posts: 18
Joined: Thu Dec 27, 2018 5:12 pm

Re: custom function view in js viewer

Post by gegar » Mon Jun 10, 2019 4:08 pm

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.
Lech Kulikowski
Posts: 1637
Joined: Tue Mar 20, 2018 5:34 am

Re: custom function view in js viewer

Post by Lech Kulikowski » Mon Jun 10, 2019 9:31 pm

Hello,

Thank you for the provided solution.
Post Reply