Conversion and layout problem

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
vijo
Profound User
Posts: 28
Joined: Thu Jun 25, 2015 4:47 pm
First Name: Vincent
Last Name: Jonis
Company Name: oo2
Contact:

Conversion and layout problem

Post by vijo »

Hi again,

I'm trying to insert some fields into a mobile device layout automatically during conversion of DDS files.
I've put the following code into my conversion theme:

Code: Select all

    
    "process field": function(field, item, isSubfile, isWindow){
        if (!isWindow){
          item.layout = "MainPanel";
          if(field.row <= 2) {
            item.container = "1";
            console.log(item);
            item["css class"] = "top-line";
          } else {

              item.container = "2";
          }
        }
      },
    "process fkey": function(keyword, item, format, member) {
          item.layout = "MainPanel";
          item.container = "3";
          console.log(item);
    },
    
fkeys buttons are OK, they are correctly inserted in the bottom container of the layout but others fields are not.
In the browser console, they seem to be fine:

Code: Select all

Object { id: "constant1", field type: "output field", value: " GESTION DES EMPLOYES ", css class: "ld-constant", left: "240px", cursor column: "30", top: "20px", cursor row: "1", css class 2: "top-line", layout: "MainPanel", container: "1"}
but if i save to a json file here is what i get:

Code: Select all

{ "id": "constant1", "field type": "output field", "value": " GESTION DES EMPLOYES ", "css class": "top-line", "left": "240px", "cursor column": "30", "top": "20px", "cursor row": "1", "css class 2": "top-line" }
I don't understand how these attributes (layout and container) are lost.
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Conversion and layout problem

Post by David »

It could be that the "process field" hook runs before "MainPanel" is rendered. I assume "MainPanel" is added using the theme's "items" array. "process fields" is dealing with items converted from original DDS screen components...

Try using the "add enhancements" hook to do that, does it work? "add enhancements" is a lot more capable. It runs at the end of the process, when the converted record format is complete.

You can use it like this:

Code: Select all

...
"add enhancements": function(format, isSFL, isWin, srcMember, ddsKeywords)  {

  var screenPropsObject = format.screen;
  var widgetsArray = format.items;

}
...
The widgets array should include everything except for Grids, there is a separate "grid enhancements" hook for those.
vijo
Profound User
Posts: 28
Joined: Thu Jun 25, 2015 4:47 pm
First Name: Vincent
Last Name: Jonis
Company Name: oo2
Contact:

Re: Conversion and layout problem

Post by vijo »

Thanks David,

Code: Select all

I assume "MainPanel" is added using the theme's "items" array. "process fields"
Actually it was added via the add enhancemt hook. Now, adding it using "items" array, this function does the trick:

Code: Select all

  "process field": function(field, item, isSubfile, isWindow){
      var panelId = field.memberName + '_' + field.formatName + '_MainPanel';
      if (!isWindow && !isSubfile){
        if(field.row <= 2){
          item.layout = panelId;
          item.container = '1';
          item["css class"] = "top-line";
        } else {
            item.layout = panelId;
            item.container = '2';
        }
      }
    },
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest