Render layout from XML code at runtime

Idea created by Vincent_L on May 19, 2016
    Active
    Score6

    Hi,

     

    If we could create layout programmatically it would be awesome, for instance you could have list view with variable column numbers, user would be able to add some, or reorder them. The possibilities would be tremendous.

    I've thought about this a while ago, but I didn't know how to implement it in a easy way. Today, it stroked me. We already pretty much have everything we need : Layouts can be cut and pasted, and via XML.

     

    So if we could tell filemaker just before the layouts starts to render, to use a calc field result rather than the saved structure it would be awesome. Of course the resulting layout structure would be cached, till the developer doesn't ask to refresh it.

     

    It will be very easy for use to create that XML code. Even for newbies : you would create a layout the usual way, you'd cut and paste it, to examine the XML, and you would just do the modification you want to.

    For my list view columns examples, you would need to create the layout with 4 columns, get the xml, and then create a fish column, get the xml.

    You then would just need to compare the 2 in a text processor, and you'll be able to derive it for 5,6,7,8,10 columns.

     

    Of course that would be a Filemaker Advanced only feature (so it wouldn't add complexity for the average joe).

     

    Here's a way to implement it : in the layout setup, I would add an xml structure code global variable field. We would be required to put a global variable name like $$this_layout_xml.

     

    When he wants, the dev would populate that $$var with valid xml code. Then when Filemaker would have to render that layout, like it does today, it would first check if there's a non empty $$var in its' layout setup, and if so, it would check the xml validity, and then render the layout.

    Filemaker would probably store it as binary to cache it, and it would store the MD5 of the $$variable. It would only recreate the layout in situation filemaker would redraw it like today (or if the dev ask to), but only if that MD5 changes.

    Anyway, the time spend to create from xml is not that much, today copy or pasting an xml layout is fast enough, so user won't notice it.

     

    That feature would only work on totally blank layouts. Filemaker GUI won't allow you to set the $$var in the layout setup if there's something on the layout. On layout mode, in the middle of the layout, filemaker would display the $$var name, so the dev would see immediately that this layout must be rendered. Filemaker layout setup gui would also check fo the uniqueness of that variable in the current file.

     

    Of course, all of this would be session based, so the rendering would be only stored in the current session.

     

    There maybe some xml to add, because I didn't see how was the header and footer part declared in the xml. This would probably ahem the side effect of allowing us to cut and paste layouts in the layouts list panel.

     

    This would be a total game changer (and if will allow devs to be even more productive).