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 »

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

Re: custom function view in js viewer

Post by Andrew »

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 »

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 4878 times
1.jpg
1.jpg (59.38 KiB) Viewed 4878 times
report.zip
(1.79 MiB) Downloaded 230 times
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: custom function view in js viewer

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

Re: custom function view in js viewer

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

Re: custom function view in js viewer

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

Re: custom function view in js viewer

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

Re: custom function view in js viewer

Post by Lech Kulikowski »

Hello,

Thank you for the provided solution.
Post Reply