How to deduce the viewPath for getSelectedModel - jspresso

From an action in a view that is made of multiple borders, splits, and so on, I would like to reach data that are situated in different tables of the view.
To do that, I try to deduce the viewPath parameter for the getSelectedModel, getModel methods.
What is the structure of the view, how to navigate between the different tables and deduce the viewPath in order to call the getSelectedModel / getModel... ?

The view path is an array of indexes that allows to navigate from a view to another one in the containment hierarchy. It is used in several methods of the AbstractActionContextAware class that is extended by all actions, but that you can also extend from any application class that would need utility methods to explore the action context.
The rationale behind this view path is to start from the view from which the action was triggered and to follow the view path to reach the target view and, for instance, get its selected index.
The navigation rules are the following :
a negative step index (-n) in the path means navigate up to the n'th parent
a positive step index (+n) in the path means navigate down to the n'th child
The index of the child view when a positive step is found depends on the type of container you're on. Here are the rules :
children indexes are zero-based.
the children of a border container are indexed following this fixed order : north, west, center, east, south. I one child is missing then it is not taken into account, e.g. in a border with only a north and center children views, the center child will have index 1.
the children of a grid container (either even or constrained), tab container are indexed following their order of declaration.
the children of a split container are indexed from top to bottom or left to right depending of its orientation.
For instance, given the following UI :
split_horizontal {
left {
tabs {
form
table('A')
}
}
right {
border {
top {
form
}
center {
table('B')
}
}
}
}
the view path from table `A` to table `B` will be :
[-1, -1, 1, 1]

Related

Hawaii template Categories Sidebar Menu

Is there a way to have the categories sidebar menu start in the expanded state? Currently it starts out collapsed and requires the user to expand the top level categories to view the ones underneath.
My store has only one main category right now and I would like to have it expanded unless the user chooses to collapse it
here is a link to the demo page as my site has not been published yet.
http://hawaii-demo.mybigcommerce.com/
[
Since the category list is controlled by a snippet, you would need to use javascript to autoselect/autoexpand that particular parent category.
Something like:
$(document).ready(function(){
if ($('li:contains(parentCategoryName)').hasClass('expandable') {
$(this).addClass('collapsable');
$(this).removeClass('expandable');
}
else {
return null;
}
});
I haven't tested the above script, but that would be one of my first tries. It may require tweaks. You should replace "parentCategoryName" with the name of your parent category that you want to expand.

how to get child properties of the div object for rational functinal tester

in my application i have a dropdown which is div object.the dropdown contain names and checkboxes.i need select the checkbox based on name. checkbox dont have any name.just index.can any one suggest how to get chaild items or properties of the objects for div object.
and the second question is i have tree view .which is teleric object.RFT is unable to find the object.it identifying as one all tree view is one object.its not identifying the childs,sub tree items....
so please help me on this two issues.
Hi you can get the checkboxes as follows:
void getCheckBoxes(TestObject parentDiv)
{
TestObject[] checkboxes = parentDiv.find(atDescendant(".class","Html.INPUT.checkbox"));
System.out.println("Found " + checkboxes.length);
//Go through them , and decide which one to select.
for(TestObject checkbox: checkboxes)
{
System.out.println("Checkbox Value: "+ checkbox.getProperty(".value"));
}
}
you can call the above method and pass it the parent DIV object.
About the second question:
You have not mentioed how does RFT recognize the one object for the tree ( means which proxy does it use as per the object map's adminitrative properties for that object).
Usually controls like tree /grid etc are recognized as one control and the items of these controls as "Subitem" which are found by specifying subitem as atPath("xyz->abc") etc.

Add compound node on demand cytoscape.js

I was wondering how feasible is to add some compound elements (nodes) "on the go".
Scenario:
I have a network with nodes from n1...n10 and edges. Depending on the button the user clicks, it redraws my network including nodes inside a compound node.
Example:
When you open the graph, you have n1..n10, without compounds, but when you click on a pre-defined button, my new graph now would be:
A new compound node with n1:n5 inside (parent), and the rest n6:n10 would stay the same (outside compound).
How feasible is it ?
I've tried :
cy.batchData({
"5": {
parent: "n0" // new element I added earlier
}});
to update my element id=5 to have n0 as parent, but it haven't worked.
The main idea is to represent data (graph) with biological insight, where the "new compound area" would be a pathway or a metabolic path (or whatever I want to represent there), one by one, so the visualization won't be a mess.
Thank you.
You can't change the parent field; it's immutable. You may have to remove the elements and add the second (resultant) graph via eles.remove() and cy.add() respectively.

Titanium get current view on scrollableView and add an item

I have a scrollableView with several views inside and I'd like to add item to some of these view if they meet a certain criteria, like if they have data attached or not. Also I'm using Alloy, here's my markup
<ScrollableView id="scrollableView">
<View id="view" class='coolView'></View>
...
</ScrollableView>
To know if there are data attached I check the currentPage attribute like so:
function updateCurrentView(e) {
currentView = e.currentPage;
}
But I have no idea how to add an item to the current View.
Edit: To add some clarification, I have a label which when clicked allow me to choose two currencies, when chosen these currency pairs are saved in the database and should be displayed instead of the label. So my guess was to check whether the current view has currency pair saved.
There are 2 things to take care of here:
1.Whenever a currency is selected,immediately label on that particular view will change.
2.Whenever the scrollableView is loaded,it must always refer to the database if a currency is selected.
First one can be done as:
1.Get the instance of scrollableView using the getView method of alloy controller.Pass the id of the scrollableView to it.Lets call it myScrollableView.Refer this for more info.
http://docs.appcelerator.com/titanium/latest/#!/api/Alloy.Controller
2.Use var currentView=myScrollableView.getCurrentPage() to the get the current page which will be a number.
3.Now use the scrollableView instance to get all the views.
var viewArray=myScrollableView.getViews();
4.viewArray[currentView] will give you the view of current page.After you have got the view you can change the desired label using:
viewArray[currentView].children[positionOfTheView]
The "positionOfTheView" can be obtained by printing the viewArray[i].children array using Ti.API.info.
Second thing can be accomplished as follows:
1.Get the instance of scrollableView using the getView method of alloy controller.Pass the id of the scrollableView to it.Lets call it myScrollableView.Refer this for more info.
http://docs.appcelerator.com/titanium/latest/#!/api/Alloy.Controller
2.Now use the scrollableView instance to get all the views.
var viewArray=myScrollableView.getViews();
3.This is a JavaScript array of all the views in the scrollableView. Now iterate through this array and according to the data in the database,change the concerned view using:
viewArray[i].children[positionOfTheView]
The "positionOfTheView" can be obtained by printing the viewArray[i].children array using Ti.API.info.

ExtJS grid 'reset'

I'm on ExtJS 4 and using an MVC approach. I've created a simple grid view class, and have added a componentquery type 'ref' to that view in my controller. Within the initial grid view itself I set several columns to be hidden and some to be visible by default. The rendering of the grid with those settings is all working fine.
Then I have a button that, when clicked and based on some other conditions, will make some of the initially hidden grid columns visible. This works as well.
But what I need is a way to later 'reset' the grid to its initial view (with the correct columns hidden/visible, as they were initially).
I've tried various permutations of the following with no effect:
var theGrid = this.getTheGrid();
theGrid.reconfigure(store, theGrid.initialConfig.columns);
theGrid.getView().refresh();
I suppose I could loop through every column and reset its 'hidden' state, but would think there's a way to just 'reset' back to what's set in the class? Advice?
SOLUTION UPDATE
Appreciate the pointer from tuespetre. For anyone coming along in the future looking for specifics, here is what was needed (at least for my implementation):
Within the view, moved the column defs into a variable
Within the view, columns ref within the class becomes:
columns: myColumns,
Within the view, the following function created within the class:
resetGrid: function(){
this.reconfigure(null, myColumns);
},
Within the controller:
var theGrid = this.getTheGrid();
theGrid.resetGrid();
You will just need to create a function on your view class to encapsulate that functionality.