Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I want to filter the children of one tree node using its property.
In document type I have in property called 'Category' which is multi node tree picker type property.
string artId = "1251";
var allSliders = Umbraco.TypedContentAtRoot().Where("DocumentTypeAlias == \"Slider\"").FirstOrDefault().Children;
var categorySliders = allSliders.Where(c => c.GetPropertyValue("Category", true).Equals(artId);
But it is not filtering data with specified condition. Please guide me where I am wrong? where the mistake?
Have you looked to see if allSliders is returning the correct list of nodes?
the next thing I would look at is the Where clause, a multi node picker will return a list of node IDs in a coma separated list (1234,1235,1236). So is the where clause trying to see if any match and return that node to the list? or is it trying to return just that specific ID.
If you want to return the node you can check if Category contains the ID, like so:
var categorySliders = allSliders.Where(c => c.GetPropertyValue("Category", true).Contains(artId);
If you want to just return the ID you will have to split the category picker and put it to a list then return the correct ID from the list.
this link should help if you are trying to achieve the latter: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/multinode-treepicker
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted