Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Bound mode with text (html) node  (Read 266 times)

0 Members and 1 Guest are viewing this topic.

Martin Ares

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Bound mode with text (html) node
« on: October 21, 2011, 02:07:24 PM »
Hi,

I would really like to use the bound mode in my program, I believe this would facilitate my work a lot.  I actually have NodeTextbox nodes displaying HTML, and all my attempts failed.  I can effectively bound nodes to an object, but unable to display text (html).  Please help.

Thanks,

MA

Ruslan

  • Flexible TreeView Team
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 569
Re: Bound mode with text (html) node
« Reply #1 on: October 21, 2011, 04:05:33 PM »
Hello Martin,

This code works as you need on the latest version of Flexible TreeView:
Code: [Select]
class Foo
{
  public string Text { get; set; }
}

var list = new List<Foo>
{
  new Foo { Text = "<b>Sample bold text</b>" }
};
tree.NodeControlPopulating += tree_NodeControlPopulating;
tree.DataBinding.Validate = true;
tree.DataBinding.DataSource = list;

void tree_NodeControlPopulating(FlexibleTreeView pTreeview, NodeControlPopulatingEventArgs pArgs)
{
  var tb = (NodeTextBox) pArgs.NodeControl;
  tb.SupportHtml = true;
}

As a result, you`ll see bold text that`s bound to the data source.

Martin

  • Guest
Re: Bound mode with text (html) node
« Reply #2 on: October 23, 2011, 10:26:09 PM »
Thanks for the hints.  However, I mislead you; I am using the NodeExpandableTextBox NodeControl.  Is there any way to populate the description field?  I tried to replace NodeTextBox by NodeExpandableTextBox in the NodePopulating event, but no success; "unable to cast from NodeTExtBox to NodeExpandableTextBox".

Thanks for your time.

Ruslan

  • Flexible TreeView Team
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 569
Re: Bound mode with text (html) node
« Reply #3 on: October 24, 2011, 01:12:05 PM »
Flexible TreeView doesn`t limit you even in bound mode. You can decline any node controls population and add the own one which would be bound to an object from your data source. The code below replaces auto-populated textboxes by the expandabletextbox which is bound to the Text & Description data object`s properties:
Code: [Select]
class Foo
    {
      public string Text { get; set; }
      public string Description { get; set; }
    }

      var list = new List<Foo>
                   {
                     new Foo
                       {
                         Text = "<i>Title</i>",
                         Description = "<b>Description</b>",
                       }
                   };
      tree.NodeControlPopulating += tree_NodeControlPopulating;
      tree.ColumnPopulating += tree_ColumnPopulating;
      tree.DataBinding.Validate = true;
      tree.DataBinding.DataSource = list;

      var ctrl = new NodeExpandableTextBox();
      ctrl.DataFieldName = "Text";
      ctrl.DescriptionDataFieldName = "Description";
      ctrl.TitleSupportHtml = true;
      ctrl.DescriptionSupportHtml = true;
      ctrl.AttachTo(tree);
      ctrl.AttachToColumn(tree.Columns[0]);
      ctrl.IsInBoundMode = true;

      tree.Options.Selection.HoverStyle = eHoverStyle.SoftSelect;
      tree.Options.Node.AutoNodeHeight = true;


    void tree_ColumnPopulating(FlexibleTreeView pTreeview, ColumnPopulatingEventArgs pArgs)
    {
      if (pArgs.FieldName == "Description")
        pArgs.Cancel = true;
    }

    void tree_NodeControlPopulating(FlexibleTreeView pTreeview, NodeControlPopulatingEventArgs pArgs)
    {
      if (pArgs.FieldName == "Text" || pArgs.FieldName == "Description")
        pArgs.Cancel = true;
    }

Martin Ares

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Re: Bound mode with text (html) node
« Reply #4 on: October 31, 2011, 01:49:36 PM »
Thank you, this certainly works.  As I am progressing with the bound mode, I face new challenges that were easily addressed before (unbound).  For instance, based on your last piece of code, I am trying to:

1) Add a NodeCheckBox and a NodeImage nodecontrols, both linked to the bound object. 
2) Enable the NodeCheckBox to display ThreeCheckState mode; "Undefined" state, would be displayed whenever a mix of "checked" and "unchecked" children nodes are present below the actual node. ie: automating the check status of a parent node based on its children nodes check states.

I am convinced that Flexible Treeview can address such requirements because it is so versatile, but I have been unfortunate in my attempts to do so in bound mode.  I would really appreciate if you could take some time again to help me out.

Thanks.

Martin Ares

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Re: Bound mode with text (html) node
« Reply #5 on: November 03, 2011, 08:50:57 AM »
Good morning,

Well, surprinsingly I was able to have all the NodeControls in place; for some reason, it did work when I decided to test in a new (dummy) application.  I'll have to troubleshoot to understand the root cause.

Only part left is to manage the threecheckstate in bound mode (hierarchical tree).  I can easily bind to a bool property to manage the check/unchecked status, but still unable to manage the checkstate property (check/unchecked/undefined), and not certain about the proper way to manage impact of a checkstate change on the parent and child nodes.

Let me know if you can help,

MA

Ruslan

  • Flexible TreeView Team
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 569
Re: Bound mode with text (html) node
« Reply #6 on: November 03, 2011, 03:03:54 PM »
Sorry for late response. We`ll check how you can bind an object with ThreeCheckState enabled and answer here.

Ruslan

  • Flexible TreeView Team
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 569
Re: Bound mode with text (html) node
« Reply #7 on: November 04, 2011, 07:22:18 AM »
Martin,

Unfortunately, you cannot enable ThreeCheckState in bound mode which will work in automatic mode. We have this feature requested couple of times, so seems it is time to implement it. We`ll contact you later with results.

Ruslan

  • Flexible TreeView Team
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 569
Re: Bound mode with text (html) node
« Reply #8 on: November 11, 2011, 04:59:05 PM »
Hello Martin,

Please check you registered e-mail for the installation of updated Flexible TreeView with ThreeCheckState & InteractiveCheckMode support in bound mode.

As always, we`ll be happy to answer to your questions regarding using these new features in your project.

Martin Ares

  • Customer
  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Re: Bound mode with text (html) node
« Reply #9 on: November 14, 2011, 01:30:23 PM »
Thanks for your impressive responsiveness.  I did install the revised tool and followed your instructions.  Everything is running smooth now. :)
 

Copyright © 2006-2012 ARMSoft. All rights reserved.