API
Version 7.x > API > Remove TreeNode from TreeNodeDataSet View modes: 
User avatar
Member
Member
yevgen.fesenko-bellmedia - 10/29/2012 12:27:46 PM
   
Remove TreeNode from TreeNodeDataSet
Hello,

I have two TreeNodeDatasets A an B. They may have some common TreeNodes, but may not.

I wish to exclude elements of B which are found in A, from set A.

Code:
var pinnedArticles = TreeHelper.GetDocuments(CMSContext.CurrentSiteName, "/Articles/Pinned-Articles/%",
CMSContext.PreferredCultureCode, false, "custom.article", null,
null, 1, true, 5);

var taggedArticles = TreeHelper.GetDocuments(CMSContext.CurrentSiteName, "/Articles/%",
CMSContext.PreferredCultureCode, false, "custom.article",
whereCondition, null, 5, true, 5);

if (pinnedArticles != null)
{
foreach (var article in pinnedArticles)
{
article.NodeCustomData.Value = "isPinned";
if (taggedArticles.Any(m => m.DocumentGUID == article.DocumentGUID))
{
var articleToRemove = taggedArticles.First(m => m.DocumentGUID == article.DocumentGUID);
taggedArticles.Items.Remove(articleToRemove);

}
}

I get a NullReferenceException on the highlighted line. Inspecting the code, however, shows that "articleToRemove" is not null.

Any assistance would be appreciated.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/8/2012 8:27:59 PM
   
RE:Remove TreeNode from TreeNodeDataSet
Hello,

This was regrettably a bug in the current release. This issue should be fixed in the hotfix 7.0.7. I am very sorry for the inconvenience.

Best regards,
Boris Pocatko

User avatar
Member
Member
tim-createwell.com - 10/15/2013 12:37:32 AM
   
RE:Remove TreeNode from TreeNodeDataSet
Hi there, was this issue fixed in hotfix 7.0.7? The reason being, I'm encountering it and I'm running hotfix 7.0.57...

Any help would be greatly appreciated.

Thanks,
Tim.

User avatar
Member
Member
kentico_sandroj - 10/15/2013 4:35:55 PM
   
RE:Remove TreeNode from TreeNodeDataSet
Hello,

It looks like there is still an issue with this approach. I will get more clarification and report back but in the meantime you could use a standard .NET method.

Please let me know if you have any questions.

Best Regards,
Sandro