JSCalculation returning media not working

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

JSCalculation returning media not working

Postby jasantana » Fri Jan 29, 2016 5:38 pm

Hi all.

I have added a calculation to an in memory datasource created through a query that should return a media. That calculation works fine when I use it directly from the table but not when adding it to an in memory datasource. Maybe I'm missing an stupid thing, but I can't see it !!!!

This is the code in the calculation:
Code: Select all
/**
* @properties={type:-4,typeid:36,uuid:"5D89F8E6-7F40-4114-A0AC-07117824BD91"}
*/
function instruction_source() {
   //application.output('instruction_source calculation running');
   var _media = "media:///privatelogo.png";
   if (customer_type == 0 || customer_type == null) {
      _media = "media:///Qualitas_90_90.png";
   } else if (customer_type == 1) {
      _media = "media:///d2icon.png";
   }
   return _media
}


This is the code where I read the calculation and add it to my new datasource:
Code: Select all
   /**
    * JASM on 29 Jan 2016
    *
    * Get the calculation to show the source icon from the specialists_appointments table
    * Then add it as a new calculation to the claimantsDataSource data source we've just created
    */
   var _appsDataSourceNode = solutionModel.getDataSourceNode('db:/clinics_manager/specialists_appointments');
   var _instructionSourceCalculation = _appsDataSourceNode.getCalculation('instruction_source');
   var _jsDataSourceNode = solutionModel.getDataSourceNode(claimantsDataSource);
   var _jsCalculation = _jsDataSourceNode.getCalculation('instruction_source');
   if (_jsCalculation == null) {
      _jsDataSourceNode.newCalculation(_instructionSourceCalculation.code, _instructionSourceCalculation.variableType);
   }


And this is the code when I add the field to the form:
Code: Select all
   _lbl = _jsForm.newLabel('S', 285, 35, 20, 20);
   _lbl.labelFor = 'instruction_source';
   _lbl.name = 'instruction_sourcen_label';
   _lbl.styleClass = 'gridheader';
   _fld = _jsForm.newField('instruction_source', JSField.IMAGE_MEDIA, 285, 55, 20, 20);
   _fld.name = 'instruction_source';
   _fld.editable = false;
   _fld.styleClass = 'gridcell';


Any idea?

Thanks in advance
Best regards,
Juan Antonio Santana Medina
[email protected]
EAGER BEAVER 2011
EAGER BEAVER 2012
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 544
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: JSCalculation returning media not working

Postby jcompagner » Thu Feb 04, 2016 5:43 pm

i have to check if that is really supported, adding calculations to a in mem datasource
Because that is not something you can really do, a runtime created datasource is a bit different then an actual database datasource defined in the developer.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8047
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: JSCalculation returning media not working

Postby jasantana » Thu Feb 04, 2016 7:54 pm

Hi Johan. It's doable, I finally got it but not returning a media. I'm returning an html string to show the image. I will post the solution tomorrow morning.

Cheers
Best regards,
Juan Antonio Santana Medina
[email protected]
EAGER BEAVER 2011
EAGER BEAVER 2012
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 544
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 1 guest

cron