RadTreeView cannot refresh to show changes in hierarchical data source - sql

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

Related

see the list of event listeners currently attached

I want to check the list of event listeners that are added. For example, I used the code cy.on('pan zoom resize', update); and added function called update in for loop. I do this many times. I also call cy.off('pan zoom resize', update); to remove the event listeners but I want to be sure about it.
The only think I can think of is using console.log but this method might not be helpful.
I also think that in some places people forgot to remove the event listeners and just always added. With too many repetitions this might cause problems.
There is a data field in the private cytoscape object called listeners. You can see that if you:
console.log() the cy object,
navigate to _private,
then open the emitter object
and lastly go to listeners
This is the array listing all the default and user defined event listeners with some metadata like the event, type and scope of the listener.
You can access this in your code by simply calling
cy.emitter().listeners
The question now is, why do you need this information in the first place? Normally, you should be just fine if you call cy.off('eventXY', ...) before using any cy.on('eventXY', ...). Are you sure you need this for your application to work? Maybe elaborate more on the core problem (why you want these information in the first place).
Thanks and have a great day!

Treelist in DevExpress (how to use Focus Change event)

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?

Why is the Webbrowser control DocumentComplete event fired for top level frame first?

Based on this article on MSDN: How To Determine When a Page Is Done Loading in WebBrowser Control, and from past discussions on StackOverflow, I would assume that in case of a document with multiple frames, the DocumentComplete event would fire multiple times, and the last time would be for the top level frame.
However, using the exact sample code from the above-mentioned MSDN link, I find that if there are multiple DocumentComplete events when doing a Navigate to a URL, the condition is satisfied in the following code the first time, not the last time as the article seems to indicate. Subsequent invokes of DocumentComplete seem to be for lower level frames, since the condition fails.
IUnknown* pUnk;
LPDISPATCH lpWBDisp;
HRESULT hr;
pUnk = m_webBrowser.GetControlUnknown();
ASSERT(pUnk);
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
ASSERT(SUCCEEDED(hr));
if (lpDisp == lpWBDisp )
{
// Top-level Window object, so document has been loaded
TRACE("Web document is finished downloading\n");
}
lpWBDisp->Release();
I am not sure why the behaviour I observe is exactly opposite of what it is supposed to be as per the documentation. Any pointers on this would be appreciated.
Background: I am using this code in a dialog-based VC++ / MFC application, and in the DocumentComplete event I want to get certain statistics when the document is fully loaded. So I was trying to use the above code to detect that a particular instance of DocumentComplete firing is when the page has fully loaded.
IMO, the most reliable way to get notified when the page has been fully loaded is to attach to window.onload DOM event for the top window object (IWebBrowser2::get_Document, IHTMLDocument2::get_parentWindow), when DocumentComplete is fired for the first time for a particular navigation. Then, onload event for the top web page will be fired when all inner frames have been loaded. This answer illustrates how it can be done in C# and this answer may help to get it done in C++.
The MSDN doc seems right to me: the last DISPID_DOCUMENTCOMPLETE is the one fired for the main frame.
I can't reproduce your problem for http://www.microsoft.com/ as that link gives me the final http://www.microsoft.com/fr-fr/default.aspx which is a single frame.
I don't like the way the sample code is testing for the Main Browser (equality of 2 IDispatch pointers). What I do is this:
QueryInterface the IDispatch for an IWebBrowser2
Make a true COM equality test, that is "comparing the IUnknown" from the 2 IWebBrower2 (I do it with the IsEqualObject method from the CComPtr template.

Can SpineJS block the UI when updating?

One of the stated SpineJS goals is to make the entire UI non-blocking (i.e. display the change to the user, even though it might have not been updated successfully on the server side yet).
Can it be used in a standard "blocking" manner?
Yes it can. Look here under "callbacks":
http://spinejs.com/docs/ajax
You can basically block the UI at any point, and I do it for things that just can't be deferred to the server. Note that I don't even use the ajaxSucess() event, but just custom bindings for events. Here is an example use case in meta programming:
Bind 'clickHandlerFinish' event to clickHandlerFinishWork()
Bind 'click' event on button a to clickHandler()
User clicks on button a
clickHandler() gets fired
clickHandler disables the button and blocks the UI
clickHandler makes an AJAX call to the server to do work
(Remember UI is still blocked)
AJAX call finally returns, and fires the clickHandlerFinish() callback
clickHandlerFinish() unblocks the UI, re-enables the button, and presents the new changes
I've used this successfully on a few instances. Works great for me!

Is calling doLayout() method a must after adding child to a parent?

In our application, there is a tabpanel in which we are adding/removing the panel dynamically.
The panels get added at the click of a menu item by the following code in menu handler:
Ext.getCmp('mainTabPanelId').add(getPanel());
Here getPanel() method returns the panel after creating it.
Assuming that the id of main tab panel is mainTabPanelId and that of the child panel is panelId, in this context, could someone guide at the following:
Is it necessary to call doLayout() on mainTabPanel after the add method?
Should the doLayout() be called on the mainTabPanel or on the newly added child panel, that is, Ext.getCmp('mainTabId').doLayout() or Ext.getCmp('panelId').doLayout()?
Will a call to doLayout() take care of all the issues related to rendering, like scrollbars esp.?
The method getPanel() should return an already created panel (using Ext.create) or should it return a config object (having xtype:'panel')? Which one should be preferred for better performance keeping time in mind?
AbstractContainer::add()
<...> If the Container was configured with a size-managing layout manager, the Container will recalculate its internal layout at this time too.
So you don't have to do 1 — 3 because:
AbstractContainer::doLayout()
<...> The framework uses this internally to refresh layouts form most cases.
AbstractContainer::defaults
For defaults to work, the child items must be added using {xtype: ......} NOT using Ext.create("widget.type",{}) © roger.spall
So I'd prefer return configuration object instead of components itself.