Page 1 of 1

[RPG] - LongRange Offline Horizontal Table

Posted: Fri May 19, 2017 1:41 am
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

Re: [RPG] - LongRange Offline Horizontal Table

Posted: Fri May 19, 2017 10:33 am
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.

Re: [RPG] - LongRange Offline Horizontal Table

Posted: Wed May 24, 2017 3:30 am
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
}


Re: [RPG] - LongRange Offline Horizontal Table

Posted: Wed May 24, 2017 11:21 am
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 });
    }
);