Flex: How can I Load data, then create required components? - apache-flex

I have a flex application that has three tabs. Each of these tabs has a component that loads a ‘form’ that has a dropdown combo box. These combo boxes depend on external data in order to populate correctly. Currently the first tab is being created and the data that should be populated in the combo box is not in there. The combo box for the second tab is populated with the required data.
What I’d like to do is create an event that is dispatched after the data is loaded. When this event happens I’d like to then create these tabs, or the components of the tabs. Is there a way to wait for the data to be loaded before the application creates the components?

You could create the components in actionscript.
this code will create a ComboBox:
var newBox = new ComboBox();
newBox.dataProvider = aDataProvider;
// You could alternativley use (v/h)box.addChild(newBox)
// to add it as a child of a specific element
Application.application.addChild(newBox);
You can use that sort of technique to create the components in actionscript, you will still need to set all the properties that are usually set in mxml, but they all have the same names.

Related

Specifying the index of dynamically created QML components within a Layout?

I'm using Javascript to dynamically create a QML component via:
var component = Qt.createComponent(qmlURL)
var item = component.createObject(parentLayout, properties)
In this case, the parentLayout is a ColumnLayout and it always creates the object at the end of the children list (which means it is displayed at the bottom of the column).
How can I specify the index position within the children of where the object is placed, or how can I move it in the children list post instantiation?
(I tried assigning parentLayout.children[i] to no avail)
Use case: I have a large existing multi-level (nested) Menu system that is static, but I'd like insert and remove custom submenu items in the hierarchy in response to external plugins registering/unregistering via a service API. While we could completely re-implement the menu system as a dynamic treeview, that seems overkill just to insert a couple menu subitems dynamically.

How to get the tableview object which is inside a tab which inturn is inside a Tabpane Javafx

I have a tabpane which has 13 tabs and each of those thirteen tabs have 13 table views as well as some components like buttons and labels in each tab
I want to get the tableview object by selecting the tableview from a particular tab.
Like if the focus comes to a table view i can get to know from which tab it has come so that i can use the particular tableview object in a method.
As i have a method that will do a task which is same just the tableview changes depending upon the tab , si if i can get the tableviews i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact I am not sure how to move further as beacuse what i exactly want is like i have a method that will do a task which ia same just the tableview changes depending upon the tab , so if i can get the tableview obj of each tab i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact node.
The logic behind the tab and tab pane is a fxml component . I am using fxml component to develop my application.
eg:-
Set<Report> selection = new HashSet<Report>(businessEventReport.getSelectionModel().getSelectedItems());
here the businessEventreport is a table view in a table , i want to get the particular tableview by focusing on the particular tableview of the tab.
how do i do that .
i can get the tabs using
SingleSelectionModel<Tab> selectionModel = tabpane.getSelectionModel();
selectionModel.getSelectedItem().getContent();
but i am stuck after that.
One solution would be to assign each of your TableViews an identifier. This
identifier would then be used to discover the TableView from amongst the set of controls on each tab (or the whole Scene) using the lookup method.
To set the identifier for each TableView use the Node.setId method.
tableView.setId("MyTable")
To find the TableView from the TabPane use the Node.lookup method.
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem()
Node selectedContent = selectedTab.getContent()
TableView selectedTable = selectedContent.lookup("#MyTable")
The lookup method searches through the children of the Node used to perform the lookup. This gives you the flexibility to either assign each of your TableViews a unique identifier, allowing lookup from TabPane itself or to assign them all the same identifier and use the parent Tab to discover the TableView (example above).
The lookup method uses a CSS selector to find controls so identifiers aren't mandatory. An alternative approach would be to use the class type and state of the TabPane and TableView to form a selector. Something like the following (untested).
selectedContent.lookup(".tab-pane > .tab:selected > .table-view")

Flex 4.5: Custom component doesn't get visible in custom ItemRenderer

I'm developing a dynamic ItemRenderer to edition in line for Spark DataGrid.
With the Click event on Edit button (first column), I'm refreshing the cell's row using grid.invalidateCell(x,y); inside this custom ItemRenderer, in the function prepare, I'm evaluating an 'editing' dynamic property to hide/show (.visible/.includeInLayout) the default Label or Control for edition; I'm not using actually the itemEditor DataGrid's operation, just simulating this functionality.
Everything goes well with standard spark components for edition: TextInput, ComboBox, etc, but custom components (extended from SkinnableContainer) doesn't get visible, just randomically on first row sometimes.
Is there any specific interface that custom components must implement to work inside an ItemRenderer??
The problem was this property: customComponent.includeInLayout; once you set it to false, it has problems to get visible again. I think it's bad idea to use includeInLayout inside an ItemRenderer.
Now I'm working only with .visible=(false/true) and .x coordinate.
Thanks.

Toggle viewstack within child component

I have a viewstack with two tabs.
In one of them there is a data grid shows a list of notes. The other one is includes a form that can edit notes or crates new note. I want the user to be able to add new note or edit existing note when clicks an item in data grid. I mean when user clicks an item the viewstack must become editor.
You can use the "selectedIndex" or "selectedItem" property on the viewstack to switch the active view. In your case, an event should be dispatched that bubbles up to the component containing the viewstack. When it arrives, the viewstack's active view can then be changed.

Forcing custom item renders to refresh

I have an AdvancedDataGrid. One of the columns in the grid displayed with help of custom render. During the application run, I set another custom render to the same column. When I scroll data in the grid (change values for the custom renders) they display new view correctly.
I want that they dispaly new view automatically (when I set them): so I think I have to call them and tell tham to refresh rgeir views. Any idea how to do this?
Use invalidateList()

Resources