[RPG] - LongRange Offline Horizontal Table

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
mwilliams
Posts: 20
Joined: Fri May 19, 2017 1:34 am

[RPG] - LongRange Offline Horizontal Table

Post by mwilliams »

Is it possible to create a horizontal table for an offline app. I'm hoping there is a collist property like there is a rowlist property. If it's possible, could a simple example be provided?

thanks
tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: [RPG] - LongRange Offline Horizontal Table

Post by tsupartono »

Unfortunately the built-in Table element doesn't do a horizontal table.
The only way to have a horizontal table would be to manually create 2 subforms - one for the header, and one for the body.
mwilliams
Posts: 20
Joined: Fri May 19, 2017 1:34 am

Re: [RPG] - LongRange Offline Horizontal Table

Post by mwilliams »

So if my photos are stored in an sql table and I have to programmatically create my horizontal table, how do I get the contents of the image into my row column? This is what I currently tried but doesn't work. The sql returns 2 rows in my case but the contents are null of each element in photos.

Code: Select all

function () {
     this.q_sql("SELECT PHOTO FROM SOMEFILE");
},

function (photos) {
   // Generate Columns

   for (var i = 1; i <= photos.length; i++) {
      var photo = photos[i-1];

       var image = {
              Type: "Image",
               Image: photo[0],
               Layout: {
                    Row: 1,
                    Col: 1,
                    Width: 150
                }
        };
    }

   // Add image to table
}

tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: [RPG] - LongRange Offline Horizontal Table

Post by tsupartono »

It's not currently possible to get binary data out of the table using q_sql.
Instead you'd need to use data binding that binds the element to the row it corresponds to.
For each of your element in the grid, you'd need to bind to (say) "SELECT Photo From Employee WHERE EmpID = " + EmpID

Please see the example below, it assumes that the screen has N image element called PictureN (Picture1, Picture2, and so on).
It gets the IDs of all employees in the Employee table, and then bind each Picture's Image property to the Photo field from the respective row.

Code: Select all

lrexec(
    function()
    {
        // Select employee id from the Employee table
        this.q_sql("SELECT EmpId FROM Employee");
    },
    function(rows)
    {
        var props = { };

        for(var i = 0; i < rows.length; i++)
        {
            var empId = rows[i][0];
            var elementName = "Picture" + (i + 1);
            var bindingRef = elementName + ".image.$3.sql";
            props[bindingRef] = "SELECT Photo FROM Employee WHERE EmpID = " + empId;
        }

        this.q_setProperties({ "form.fields" : props });
    }
);
Post Reply