PDA

View Full Version : Need help with a function to filter a list, please.



Paul Pratt
July 14th, 2014, 07:23
I have a list set up, and on a separate window instance I want to reuse the list, but filter the contents. For instance I have set up a skills list, and then on a mini sheet I want to reuse the list, but only want it to contain a few combat related skills, like "Dodge" , "Parry", climb, etc..

I have the entire list set to be invisible, figuring I could find the specfic skills and then set them to be visible. I could set up a button field to switch visiblity on off, but that would reside in the skill list template and effect the skills tab. I could have a seperate list, but that defeats the purpose, and forces a player to track/advance a skill in two different places.

So far, I can find the skill, it's name, but can not turn on/off the visibilty to just a specific skill. It's the whole list that is modified. I figure I need to get the ID of the skill, and am not sure how to do that. If I could find that, I should be able to set that ID node as visible and have a shortened skill list.

function FilterSkills()

local node = window.getDatabaseNode();

local basicskills = node.getChild(".basicskills");

local sCombatSkill = "Dodge" or "Parry";


if (basicskills ~= nil) then


for k, v in pairs (basicskills.getChildren()) do



if v.getChild("name").getValue() == sCombatSkill then




local ID = ("a way to find the ID number of the skill in the database")




return ID;



end


ID.setVisible(true);


end

end
end

Any help is appreciated.

-Paul

Moon Wizard
July 14th, 2014, 09:57
I'm thinking a hidden skill "type" field for each skill record, then a hidden "filter " field, and set the list to use the hidden filter to only show skills of the given type field.

It's late, so let me know if you need me to explain more.

JPG

Paul Pratt
July 14th, 2014, 17:27
I must be using the "filter" xml tag incorrectly.

I set up a hidden stringcontrol named "reaction". The value in that control is yes or no. I want to filter so I have only the "yes" skills showing. Using filter I have the <control> tag set to reaction, but I am unsure how to set up the <field> tag.

I am assuming I use <filteron> insted of <filter> since this would be a child to the skills list?

Moon Wizard
July 14th, 2014, 17:48
Yes. The filteron tag specifies the list child field/control to filter the results by, and the filter tag specifies the string field/control to use as the filter.



<filter control="filtertype" />
<filteron field="skilltype" />


Regards,
JPG