Treelist in DevExpress (how to use Focus Change event) - vb.net

I am new using Dev Express I want to use a (devexpress) TreeList as a menu in my application (vbnet). I don't know how to make a node clickable to go to a form.
Please find below the treelist that I inplement
Thx in advance

First go through the documentation: Tree List to know that how this control works and then implement data in the tree list then do navigation stuff in below manner:
To respond to change in node selection, you can handle the TreeList.SelectionChanged event. To use it as Menu then you must set TreeListOptionsSelection.MultiSelect property to false. The SelectionChanged event fires each time a node is selected or deselected in such a case.
Then you can obtain the focused node using the TreeList.FocusedNode property. Then, use its TreeListNode.GetValue method to obtain a value of a specific column.
example code in c#:
private void treeList1_SelectionChanged(object sender, EventArgs e) {
//Write your code to open a form dialog after getting information
// using the required condition that you have
Form form = GetNavigationFormForNode(treeList1.GetDisplayText(columnDep));
if(form != null)
{
form.ShowDialog();
}
}
In case of fouused Node concern:
I suggest you go through documentation section "Respond to Focus Movement" of TreeList. Then you can respond to moving focus between nodes by handling the TreeList.FocusedNodeChanged event.
The event handler receives an argument of type FocusedNodeChangedEventArgs containing data related to this event. There you can get the current Tree List node from the Node property.
Reference:
How can I get data record for focused row in TreeList?
How to get tree list selected node text?
For using navigation bar for single form implementation then check it:
How can I use office navigation bar like backstageview in winforms?

Related

RecyclerView items have an icon that have conditional databinding for visibility but it is not refreshing

I have a recyclerview that contains a list of pre-defined UI layout elements. In the pre-defined UI layout, there is an icon that is visible if the item is a type of project. If it's not that type, it is not visible. When the user enters selection mode, I set a custom variable in the adapter to hide this icon on all items, however it is not working.
I've tried using DiffUtil callback for updating the contents (i.e. returning false for contentsIsSame when it's the one with visible icon on status change), and I see it flicker, but for only one row, and it reverts.
I've tried using notifydatasetchanged, also invalidateAll, neither works.
I looked on internet for anything that is similar to my issue, but was unable to find any solutions that worked.
In the pre-defined UI layout XML for each row:
<variable
name="isSelecting"
type="boolean"/>
Then in the visibility binding (omitted other attributes):
<ImageView
app:visibleGone="#{project.isIconVisible && !isSelecting}"/>
In RecyclerView.Adapter class code that creates the list:
listItemBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_project_list, parent, false);
When the selection button is pressed, this is called:
public void setIsSelecting(boolean isSelecting){
listItemBinding.setIsSelecting(isSelecting);
This is where I tried different methods, such as listItemBinding.invalidateAll().
If I manually set isSelecting to true or false, before the list is populated, it correctly shows/hides the icons. It's just not updating when it's changed.
After digging, I realized that listItemBinding was one individual item, not the entire list. I then found this: RecyclerView - get all existing views/viewholders
I realized that I was looking at the wrong place to set the isSelected value, and it was supposed to go into onBindViewHolder, then just call notifyDataSetChanged() and it'll handle the rest.

Disable automatic select of node on click?

I'm using a VIS.JS network diagram as a menu (of sorts) with a master/detail relationship to another area of the screen. Each time a user selects a node I signal the loading of the other area. Since the load is asynchronous and can take time (1-2 sec) I'd like to prevent the network node selection from changing until the details are loaded.
Ideally I'd like for the click to invoke the callback, without changing the node selection. Then receive a notification from the detail pane that the loading is complete, and only then change the node selection through code.
I think the only thing I'm missing is the ability to disable the auto-selection of a node when it is clicked.
Is that possible?
Thanks
-John
I don't know if it'll exactly fit your need but,
I needed to create some node unselectable so I prefix my unselectable node's id with a marker.
And then
const unselectableMarker = 'header-';
network.on('selectNode', (opts) => {
network.setSelection({
nodes: opts.nodes.filter(id => !id.startsWith(unselectableMarker)), // prevent selection of headers nodes
edges: opts.edges,
});
});
I've found nothing in actual doc for preventing events in network context.
Capturing the event and preventing default behaviour should not focus the element.
handleClick (evt) {
evt.preventDefault();
// rest of code
}

RadTreeView cannot refresh to show changes in hierarchical data source

I have a rather serious problem trying to get a Telerik radTreeView to show changes in the underlying database and therefore datasource. My scenario is as follows.
In the Load event hander, the radTreeView is initialized as in the following example code:
radCommentTreeView1.DataSource = Nothing
// Initialize custom data object from custom hierarchical data source class
cdsPubCommentDataSource = New CommentDataSource(1)
radCommentTreeView1.DataSource = cdsPubCommentDataSource
// Configure radTreeView from datasource fields
radCommentTreeView1.DataFieldID = "ID"
radCommentTreeView1.DataFieldParentID = "ParentID"
radCommentTreeView1.DataTextField = "Content"
// Bind radTreeView to datasource
radCommentTreeView1.DataBind()
The page loads with radTreeView rendered correctly
User attempts to add or delete a node by clicking a button with a server-side handler ....
... so that the postback cycle begins in the server-side code, with the Load handler from (2) above running again, to rebind the radTreeView
... only after which the server-side button handler is run, successfully running an SQL command through another BLL business object (i.e., the SQL database is successfully modified ) ....
However, when the page renders after the postback, the radTreeView still reflects the original node hierarchy from (4) above, before the node was deleted in (5).
Could someone indicate how this process ought to be achieved within the cycle of a single postback - if I call DataBind on the radTreeView at the end of the server-side button handler, this does seem to pick up the database changes, but unfortunately it destroys the radTreeView's formatting with the node template, and as a result, no node databound content is rendered in any of the nodes. Obviously, the node template needs to be instantiated at the start of the page life-cycle, and if, as in this case, databinding late in the cycle disrupts the template, I cannot tell the page to 'go back' and instantiate the template again. But calling DataBind at the end of the handler would seem to me to be the intuitively correct way to approach the issue, it's just that the resulting loss of the node template prevents it from working.
I am aware of the idea of using the INotifyPropertyChanged interface for the datasource object, and already have the event in question being successfully fired up from the DataSource object, namely a PropertyChanged event that is fired at (4) when the radTreeView first rebinds on the postback, but I am not sure how a PropertyChanged event handler can help in the scenario I describe - the PropertyChanged event handler in the page is still invoked before the button handler, and so the database has not been changed at that stage. Is the PropertyChanged event the correct way forward, or is there another approach better suited for refreshing the radTreeView within a single postback cycle?
Thanks if someone can point me in the right direction with this problem.
Regards

Dojo : show() and hide() .... HOW?

I have a container element in which I create on the fly/place() a form, then another one..etc.
My goal is to switch between them i.e. hide all and show only the active form.
It hides alright, but I can't show the active back.
I tried using:
.style.display(none<->block) and visibility(visibility<->hidden)
dojo.style(...)
resize() and startup() after the changes
Several other variants i found on Internet from old dojo's
Nothing works.
/I need it to work with display, so that it does not occupy space./
Can you tell me what is the correct way to show and hide with dojo()
Also looked at this one :
How do I dynamically show and hide an entire TabContainer using DOJO?
Does not work.
The pseudo code I use is something like this :
....
//find or create the FORM element
form = dijit.byId(...);
if(typeof form != 'object') {
form = dojo.create('form', ....);
dojo.place(form,'containerx','last');
}
//hide all
dojo.query('#containerx > *').forEach(function(item){
dojo.style(item, 'visibility','hidden');// and all other variants i mentioned
})
//show only the current form
dojo.style(form, 'visibility','visible');
//if the dojo form obj was already created, then skip it
if (this.form_obj) return;
....build the form and the elements....
this.form_obj.startup()
thanx
I just answered the question in that thread you referenced in your question a few minutes ago. Basically it involved getting jQuery involved. Works great for me. I have all the tabs created statically (as opposed to programatically) and I'm able to manipulate whether they are shown or hidden with the help on jQuery. All the code any everything is in my post here:
How do I dynamically show and hide an entire TabContainer using DOJO?
Sounds like you might be looking for StackContainer functionality.
Just set things up so that the StackContainer has the dijit.form.Forms as children and you can use the selectChild method to choose what form to display.

What's the difference between .select, .show, and .load in jquery-ui tabs?

I see that there are three events fired when a tab is selected and I see the order in which the events are fired but I'm rather confused about which event to use or how these are truly different. If all three are fired, couldn't I just put my code in any of the events?
I must be missing something here. Can someone clarify?
So after messing with this more I'm going to share what I ended up doing in the hopes that it might help someone else.
I had to generate dynamic tabs based on data returned in an Ajax call. It's basically data by date where the tabs are the date and they display whatever data falls within that date.
Generating the tabs from the returned data was easy but I couldn't figure out how to write out the associated data. Finally (and I should have started here), I looked that the generated dom and noticed that a dynamically created tab also creates a div. Maybe that's obvious to some (it wasn't to me) and if it was in the documentation I missed it. Anyway, this code will generate tabs from an array and then append html to the associated div when the tab is clicked. I don't need all the variables but I thought that might make it more readable. Put the function for show before adding the tabs or it wont work!
var _sessionDates = getSessionDates(sessionData.Sessions);
var $tabs = $("#sub-tabs");
$tabs.tabs({
show: function(event, ui) {
var selected = $tabs.tabs('option', 'selected');
var _sessionDates = getSessionDates(sessionData.Sessions);
var grid = buildGrid(_sessionDates[selected]);
$('#' + _sessionDates[selected]).html(grid);
}
});
$(_sessionDates).each(function(i, dayOfShow) {
var d = dateFormat(dayOfShow, "mediumDate");
$tabs.tabs('add', '#' + dayOfShow, d);
});
Finally, I have to "scroll" through my data shown in the tab and I was able to do that with these two lines. The first line gives me the id of the div element corresponding to the selected tab (which is really the important part) and the second line just calls my method and passes in the id of the div less the '#'. My date is also my id. There's a global variable that I've changed outside of this that makes it work. I know that's bad and I'll remove it when I refactor it.
var $el = $($('#sub-tabs a')[$('#sub-tabs').tabs('option', 'selected')]).attr('href');
$($el).html(buildGrid($el.replace('#', '')));
select is triggered when a tab is clicked on, but before the tab has been shown
load is triggered after the contents of a remote tab have been loaded (i.e. a tab whose content is not part of the initial page payload, but that is loaded via an ajax call when the user clicks on the related tab)
show is triggered after a tab has been shown
The jQuery documentation makes this relatively clear, but I had to experiment in order to fully understand the difference between select and show.
This has been made more clear since the original question was asked so now the following is true:
Effectively, the functionality for "show" is now provided by "activate" and "select" is done with "beforeActivate" while "load" is still the same.
activate: (previously show) Triggered after a tab has been activated (after animation completes)
beforeActivate: (previously select) Triggered immediately before a tab is activated.
load: Triggered after a remote tab has been loaded.
Also provided are:
beforeLoad: Triggered when a remote tab is about to be loaded, after the beforeActivate event.
create: Triggered when the tabs are created.