How do I convert a child node to a parent node in a GXT treepanel? - gxt

Here, I am creating gxt tree with rood node. I dont have any data to fill the tree initially.
In the screen I have gxt grid. Drag and drop from the grid to the tree. After droping from the grid, for the data I have context menu. In the context menu selection listener I have to make this data to parent node which can accept child nodes.
FolderEnv[] folders = new FolderEnv[] {
new FolderEnv(
"Environment Hierarchy", new FolderEnv[] {})
};
FolderEnv root = new FolderEnv("root");
for (int i = 0; i < folders.length; i++) {
root.add((FolderEnv) folders[i]);
}
treeStore.add(root.getChildren(), true);

Related

How to make JSF Primefaces Tree expandable

Is it possible that all tree nodes expandable by default at the beginning?Because i bring data when i click the expand icon.
FiderRepository fiderRepository = ConversationManager
.getInstance().applicationContext
.getBean(FiderRepository.class);
FiderUtil fiderUtil=(FiderUtil) event.getTreeNode().getData();
if(fiderUtil.getId()!=null){
Integer parentId = fiderUtil.getId();
SearchParameters parameters=new SearchParameters();
parameters.setNamedQuery("Fider.findChildren");
parameters.addNamedQueryParameter("parentId", parentId);
if(parentId!=null){
List<Fider> fiderler = fiderRepository.find(parameters);
for (Fider fider : fiderler) {
TreeNode node=new DefaultTreeNode();
node=new DefaultTreeNode(new FiderUtil(fider.getAdi(),fider.getId()), event.getTreeNode());
}
}}
This is my onNodeExpand method.
Your question is not very clear. But if you want all nodes to be expanded by default, you can do it by calling the "setExpanded(boolean expanded)" method on every TreeNode during construction of the Tree.
Refer : http://www.primefaces.org/docs/api/4.0/org/primefaces/model/TreeNode.html

wxWidgets wxFrame resize in wxNotebook

I am using wxWidget to design GUI. My GUI has multiple tabs. If user resizes the Frame, if he has selected some tab, when he is switching between tabs same modified size should be maintained. i am using sizers to put all child windows.But currently this is not happening. My current code is like this
void XTab::OnPageChanged(wxNotebookEvent & event)
{
if(isActive())
{
int page = event.GetOldSelection();
if(page!=-1)
{
XPanel * panel = (XPanel*)GetPage(page);
xdmlASSERT(panel->isActive());
panel->onUIDeactivate();
}
page = event.GetSelection();
if(page!=-1)
{
XPanel * panel = (XPanel*)GetPage(page);
xdmlASSERT(!panel->isActive());
panel->onUIActivate();
}
RecalcSize();
DFrame::UpdateLayout(this);
}
}
where DFrame is derived from wxFrame and XPanel is derived from wxPanel.The size is recalculated and best size is queried in GetSizer->CalcMin() method. This happens in ReCalcSize(). I don't know the reason why size of frame set by user is not persisting. Is there any way to store modified size of all children dynamically so? can u send some code for this?

How to bind another grid on save of one grid?

I have using telerik grid in telerik window. However, on saving record in telerik window want to rebind another grid. However, grid is not rebinding. It happens only when you refresh the page. I want some method to be called once ajaxbinding for insert is done so as to rebing another grid.
This is a little tricky with the Telerik grids. Basically, you need to set a Javascript variable (flag) on submit of grid 1. Then on databinding of grid 1, if the flag is true, then rebind grid 2. Something like this:
var grid1SubmitChanges = false;
function Grid1_OnSubmitChanges(e) {
grid1SubmitChanges = true;
}
function Grid1_OnDataBinding(e) {
if (grid1SubmitChanges) {
// toggle the flag so you don't always rebind Grid2 when Grid1 binds
grid1SubmitChanges = false;
// rebind Grid2
var grid2 = $('#Grid2').data('tGrid');
grid2.rebind();
}
}

CommandBarButton on Context Menu doesn't work after ElementHost becomes visible

I have a CommandBarPopup on a the context menu in excel that contains three CommandBarButtons, one of those buttons opens a web page, the other two open a custom task pane.
If I make the custom task pane containing an element host which hosts a WPF user control visible then the any of the CommandBarButtons I have added will stop working.
Even if I close the custom task pane it will still not work.
If I do the same with a custom task pane container a web browser it seems to work fine.
Here is the code we are using
private void InitializeComponent()
{
this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
this.myView = new MyView();
this.SuspendLayout();
//
// elementHost1
//
this.elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
this.elementHost1.Location = new System.Drawing.Point(0, 0);
this.elementHost1.Name = "elementHost1";
this.elementHost1.Size = new System.Drawing.Size(780, 560);
this.elementHost1.TabIndex = 0;
this.elementHost1.Text = "elementHost1";
this.elementHost1.Child = this.myView;
//
// MyTaskPane
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.elementHost1);
this.Name = "MyTaskPane";
this.Size = new System.Drawing.Size(780, 560);
this.ResumeLayout(false);
}
So the answer was that the CommandBarButtons were being disposed once the variable scope ended which was surprising as I would have assumed they would be attached to the excel application object. Also looking at the excel commandbar, I could see the buttons there but clicking on them resulted in the click event not triggering.
Anyway I stored them in a class variable and it worked again.

qooxdoo virtual tree as menu

I have a function, which creates layout with widgets. The problem is what one of the widget is virtual tree (on left side of layout) and the second widget on the right side depends on clicked row on left side. Virtual tree works like menu, which should return value of row name to the right widget and recreate it on right side with provided data. However currently it is not recreating, but adding a new widget to the old one. How to recreate widget on the right side not adding it to the existing one (interface is similar to qooxdoo demobrowser view with tests)?
_createLayout : function()
{
// Create main layout
var dockLayout = new qx.ui.layout.Dock();
var dockLayoutComposite = new qx.ui.container.Composite(dockLayout);
this.getRoot().add(dockLayoutComposite, {edge:0});
// Create header
this.__header = new bank.view.Header();
dockLayoutComposite.add(this.__header, {edge: "north"});
// Create toolbar
this.__toolBarView = new bank.view.ToolBar(this);
dockLayoutComposite.add(this.__toolBarView, {edge: "north"});
// Create the tree view, which should create dockLayout below, when user clicks with Row value
dockLayoutComposite.add(this.getTreeView(), {edge: "west"});
// This layout should be created and recreated with clicked row value
dockLayoutComposite.add(bank.InvoiceListBuilder.createList("Tree_returned_value"), {edge: "center"});
},
getTreeView : function()
{
var hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(20));
var tree = new qx.ui.treevirtual.TreeVirtual("Tree");
tree.setColumnWidth(0, 170);
tree.setAlwaysShowOpenCloseSymbol(true);
var dataModel = tree.getDataModel();
var te2 = dataModel.addBranch(null, "Folders", true);
dataModel.addBranch(te2, "Incoming", false);
dataModel.addBranch(te2, "Outgoing", false);
dataModel.addBranch(te2, "Drafts", false);
dataModel.setData();
hBox.add(tree);
var foldercontent = bank.InvoiceListBuilder.createList("incoming");
tree.addListener("changeSelection",
function(e)
{
// this function should return row value to function: bank.InvoiceListBuilder.createList("Tree_returned_value") and create/recreate dockLayout with newly created widget from bank.InvoiceListBuilder.createList function
});
return hBox;
},
you are using a old virtual tree implementation (qx.ui.treevirtual.TreeVirtual), I would suggest to use the qx.ui.tree.VirtualTree implementation.
The next step is to use something like a controller for your view, which listen to the selection and creates widgets when the selection changed. The controller should know the container for adding widgets.
When your left side is just a list. You can also use the virtual list (qx.ui.list.List) and use a set of the tree model.
Cheers,
Chris

Resources