PDA

View Full Version : Accessing fields inside header_column in the corerpg ruleset



Simpe
May 26th, 2018, 10:02
Hi,

I'm trying to build a layer on top of the corerpg ruleset, and I'm trying to understand the column templates since they seem to help me greatly in getting the layout I want.

Right now I'm in a windowclass where I'm drawing information about an archetype and I have some sheetdata looking like this:



<anchor_column name="columnanchor" />
<header_column>
<simplestring name="name"/>
<empty textres="library_recordtype_empty_archetype"/>
</header_column>
<ft_column name="text" />


So the empty textres is just temporary to at least show something because the simplestring is failing.

The ft_column name="text" extracts the information just fine, and the current entry I'm looking at has the following layout:



<name type="string">Warrior</name>
<text type="formattedtext"><p><b>Description of warrior here.</b></p></text>


And still what comes up in my header column is the extracted string from library_recordtype_empty_race. I really don't understand why. Any help regarding understanding this problem would be greatly appriciated.

Thanks in advance,
Simon

damned
May 26th, 2018, 13:15
Welcome Simpe...

have a look in the db.xml and see the data structure.
have a look at this page: https://www.fantasygrounds.com/refdoc/DB.xcp
Use the Site Search and search on DB.getValue

And then look at examples within CoreRPG...

And use lots of Debug.console() statements to output what you are actually getting back to assist with troubleshooting.

Trenloe
May 26th, 2018, 14:03
Welcome to the forums Simpe

There are a few things that aren't quite right with how your'e trying to use <header_column>

Let's take a step back and look at the template(s) used to get to the base FG control:

header_column

<template name="header_column">
<label>
<anchored height="20">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="10" />
<left offset="10" />
<right offset="-10" />
</anchored>
<frame name="headersimple" offset="10,3,10,3" />
<center />
</label>
</template>

This is based on the label template:

label

<template name="label">
<stringcontrol>
<anchored height="20" />
<font>sheetlabel</font>
<nodrag />
<readonly />
</stringcontrol>
</template>

Which is based on the base FG control stringcontrol: https://www.fantasygrounds.com/refdoc/stringcontrol.xcp

The key thing to understand here is that stringcontrol is *not* a field control - i.e. it does not anchor on a field in the database. That would be stringfield : https://www.fantasygrounds.com/refdoc/stringfield.xcp It's a subtle difference, but an important one.

So... from this we should realise that header_column is a template for the stringcontrol FG GUI control, that is not anchored on a database field.

Secondly - we should realise that we shouldn't add another control definition *within* another FG control - this can give unpredictable results as FG will be trying to merge the code for two possibly conflicting controls. The code listed in post #1 has a simplestring control (which is based on the stringfield control) within the header_column control.

header_column is a control template that is designed to be the label for a column header within a table/windowlist. It is designed to be a text resource value from the FG XML (either static or populated from a string resource), it is not designed to be populated from a database field.

It's not clear from post #1 exactly what you're trying to do, but if you want to have a stringfield control (gets data from the database) that uses the header type functionality (i.e. using the relative anchoring based off the columnanchor control) then maybe look at the string_column template instead of the header_column template, as string_column is based off the simplestring template (which is a DB field).

Then, you will need to look at how the database is populated - as damned mentions in post #2.

Simpe
May 26th, 2018, 23:17
Hi,

Wow! Thanks for the complete and awesome response. This explains so much to me. I had never realized the field controls vs not not field controls. This really really helped all of my future development.

Many thanks!

Cheers,
Simon