Jump to content

Recommended Posts

Posted

Is there a way to set the selected node to the top of the treeview list?  Or control where in the list the selected node starts?  I've seen behavior (probably caused by me) where the selected node scrolls off of the screen and I want to push it to the top of the list.

 

-1

Posted
7 minutes ago, 1938 said:

Is there a way to set the selected node to the top of the treeview list?  Or control where in the list the selected node starts?  I've seen behavior (probably caused by me) where the selected node scrolls off of the screen and I want to push it to the top of the list.

Hello,

Sorry, can you please explain in more detail?

If possible, make a simple testcase, by specifying what behavior you want.

Posted

Yes thank you.

A easy to see example is in the Rad Studio IDE.  In the project "Structure" panel you see errors, Types, Procedures Classes etc...  Expand those.  Once a node is expanded that fills the panel with more child nodes than can be displayed, it forces that selected node to the top of the treeview panel.

 

In my case, I am using memtable to fill the treeview.  Some of the node lists are lengthy - maybe 200 or so nodes/child nodes.  I want the expanded/selected node to go to the top of the panel when I click the "plus" to expand a node.

I hope that helps.

 

 

Posted
3 minutes ago, 1938 said:

A easy to see example is in the Rad Studio IDE.  In the project "Structure" panel you see errors, Types, Procedures Classes etc...  Expand those.  Once a node is expanded that fills the panel with more child nodes than can be displayed, it forces that selected node to the top of the treeview panel.

Sorry, can you make and attach here a gif file!?

Posted

In the attached gif's

 

treeview-1 - shows how I want it to behave.  That gif is from the RAD Studio 10.3 IDE.  The selection relocates the selected node at the top.  

treeview-2 is the behavior I am getting.  The treevew  scrolls the seleted node off the screen.  I would like to make user1 at the top when I select it.

 

Thanks for your help.

treeview-1.gif

treeview-2.gif

Posted

I have tried 

UniTreeViewFolders.Selected.MakeVisible; 

But perhaps I don't understand what it is supposed to do or what event needs to contain the code.

 

Posted
6 hours ago, 1938 said:

UniTreeViewFolders.Selected.MakeVisible; 

But perhaps I don't understand what it is supposed to do or what event needs to contain the code.

LoadOnDemand = True ?

Posted
17 hours ago, 1938 said:

In the attached gif's

Thanks

17 hours ago, 1938 said:

treeview-1 - shows how I want it to behave.  That gif is from the RAD Studio 10.3 IDE.  The selection relocates the selected node at the top.  

treeview-2 is the behavior I am getting.  The treevew  scrolls the seleted node off the screen.  I would like to make user1 at the top when I select it.

I am analyzing.

Posted
On 7/22/2020 at 10:20 PM, 1938 said:

No, its set to false.  Set to true, I get incomplete redraw of treeview.  Sometimes only the root node.

Hi,

Try to use this approach:

UniTreeView.ClientEvents.ExtEvents ->

function afteritemexpand(node, index, item, eOpts)
{
    node.getOwnerTree().setSelection(node);
    
    item.scrollIntoView(true);
    //or by using Ext.defer
    //Ext.defer(function(){item.scrollIntoView(true)}, 50);
}

 

  • 4 years later...
Posted

The above does what was requested, and has helped me make a better user experience for my use of TUniTreeView.

I have a further slight modification for a slightly similar requirement. After I load the TUniTreeView (from various records in a relational database) with many items, I want to select a particular node (i.e. I search for, locate and then set structureTree.Selected), and then make sure that it is visible. 
I had thought that 

structureTree.TopItem := structureTree.Selected;

would do that. But it does not appear to do anything.

Any advice? 

UniGui 1.95.0.1592

Posted
8 hours ago, Andrew Spencer said:

would do that. But it does not appear to do anything.

Hello,

We will try to fix this in the next versions.

Let me ask, are you using the trial version?

Posted
5 minutes ago, Stemon63 said:

So it will be fix in next release?

 

4 hours ago, Sherzod said:

We will try to fix this in the next versions.

 

Workaround for now: (When TopItem is changed, the tree view scrolls vertically so that the specified node is topmost in the list view

https://www.unigui.com/doc/online_help/api/uniTreeView_TUniCustomTreeView_TopItem.html

 

UniTreeView.ClientEvents.ExtEvents ->

function afterrender(sender, eOpts) 
{
    var me = sender;
    var view = me.getView();
    view.focusRow = Ext.Function.createSequence(
        view.focusRow,
        function(d, b) {
            const record = this.getRecord(d);
            if (record) {
                var nodeEl = view.getNode(record);
                if (nodeEl) {
                    var treeEl = view.getEl();
                    var nodeTop = Ext.fly(nodeEl).getOffsetsTo(treeEl)[1];
                    treeEl.scrollTo('top', treeEl.dom.scrollTop + nodeTop, true);
                }   
                Ext.get(nodeEl).highlight("ffff9c", {
                    attr: "backgroundColor",
                    easing: 'easeIn',
                    duration: 2000
                }); 
            }
        }
    );
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...