Data Binding issue while navigation & routing? - data-binding

Today I faced a strange issue (could be a silly one) for data binding while navigating to 2nd view which is showing List of data coming from OData model and Panel at the bottom
I have replicate the code into this link - http://plnkr.co/edit/ClZqvo?p=info (You can run this as well through RUN on the Top) - Kindly run it in chrome with disabled security (Due to CORS issue)
Now the problem is when I am navigating to 2nd view (OData Table) and then Select any List Item, you will see in the bottom, the Panel will reflect the selected item (as I have used BindElement method to bind the path). After this I clicked back and then my 1st view will appear (JSON table) again I clicked on Next Button and then 2nd view will appear again. When I select the same item which I have selected previously then this time Panel will not show the selected items. This issue is coming only when I navigate back and forth and select the same item. Not able to understand what caused this?
But if I choose any other item then it will show me the selected item.
Anyone having any idea about this?
~Rahul

This is common issue when using bindElement, I have faced it too. It might be failing to resolve context of referenced entity. So, fields are not binded with respective values.
As a alternative you can use setBindingContext to bind fields within panel.
Since you are using named model, it should be specified as argument to setBindingContext.
So your code will be like
onSelect: function(oEvent) {
var oContext = oEvent.getSource().getBindingContext("odataModel");
var oProductDetailPanel = this.getView().byId("prodDetailsPanel");
oProductDetailPanel.setBindingContext(oContext, "odataModel");
}

Related

Drop dialog on a list page not disappearing automatically

When I add a drop-dialog to a list page, the drop dialog drops down when I click on it, but does not disappear when I click somewhere else.
I am trying to add my own drop-dialog, but I can reproduce this issue with standard Dynamics AX objects. I guess I am just missing some property on an object, but I just cannot figure out which one.
If you want to reproduce my problem in order to solve it, do the following:
Create a new Form. (Form 1)
Change the FormTemplate property to ListPage (Click on Yes)
Add the query MainAccountListPage to the DataSources
Create an ActionPanTab.
Add a Drop-dialog button with the menu item MainAccountListPageBalanceParameters.
Save and open the new List page by right clicking and choosing open. (or open the menu item)
In my case, when I click on Parameters, the drop dialog drops down. When I then click outside the drop-dialog, it disappears as it should.
Create a new display menu item. Set the object to the new list page (Form 1)
Drag the Menu item to any menu. I added mine to General ledger (Common)
Restore, open new workspace. Click on the new menu item in the general ledger menu.
Click on “parameters” and click outside the drop dialog.
When I do this the drop dialog does not disappear again. You can see this same drop dialog working fine on the Main Accounts list page. I have tried changing properties on both menu items, on the menu, on the form etc. I have tried different drop dialogs and different list pages. It always works on the details page and when opened from the AOT.
Am I missing a property? Is the entire way I am adding the drop dialog wrong?
The answer to the above example is.. add the MainAccountDetailPart Form part to the list page's (Form1) Parts.
With my other example, EcoResProductPerCompanyListPage, I had to add the EcoResProductVariantsPerCompanyFactBox to Parts.
I have no idea why this is, but adding a part to a list page fixes the drop dialogs. For example, adding MainAccountDetailPart Form part to a new list page not only fixes the MainAccountListPageBalanceParameters in my example, but it also fixes any other drop dialog that previously did not want to close. Removing the part the breaks all the drop dialogs in the list page again.
Thanks, FH-Inway, for the suggestion, I would have never have found the answer without your method. The solution really surprised me!

Delaying the opening of a NSPopUpButton

I've encountered the same problem as this one:
This one.
It has never been answered so far. In two words:
When you place a NSPopUpButtonCell in a NSTableView, the popUp opens before the selection in the tableView has changed.
If the menu of the popUp relies on the selection of a row of the tableView, it will be updated too late.
Solution 1: differ the opening of the popUp with a block which calls [super] a few nanoseconds later. But I don't know which method I must override.
Solution 2: use other bindings that I'm currently using (the popUp contains the NSSet of the entity selected in the table, I'm using a different controller, not the table's one, and I bind its content set to myTable.selection.theSet.
Is there something else I could do? Thanks !
Yes, if you use a view-based tableView, you can bind the popUp through the cellView it’s inside (like the other table objects you bind in this mode), and so it’s completely unambiguous and doesn’t depend on the selection.
In view-based mode, each cell in each row have is assigned an ‘objectValue’ from your original data, so you can bind directly to it, like ‘objectValue.popUpContents’.

How to mark record in grid without checkbox?

I have two grids. The first displays keys, and the second displays a list of related items in another table. Since the grids are on different tabs, I put a filter on the pageActivated method for the second grid's tab.
Some pseudo code to get my point across without posting 200 lines of x++
override page2Activated() {
dataSource2_ds.removeFilter();
dataSource2_ds.filter using grid1Field.valueStr();
}
This works nicely, as long as grid1 has rows in it when the form is opened. If there are no rows when the form is opened, even after adding a row to grid1, something doesn't get updated, and grid2 will always be blank.
Then, I tried looking at the datasource instead of the grid fields.
override page2Activated() {
dataSource1 firstTable;
firstTable = dataSource1_ds.getFirst(true);
dataSource2_ds.removeFilter();
dataSource2_ds.filter using firstTable.recID;
}
The problem with this one is that it only works if you click the checkbox next to a record.
I'd like to to work with a highlighted record in grid1, without having to click the checkbox.
Any suggestions?
Question answered in comments above. Posted as answer so the question can be marked closed.
Rather than using code to manually filter the records, link the tables using the datasource properties JoinSource and LinkType. Set JoinSource to the linked table and LinkType to Active.

Meteor and saving dropdown states

I have two collections 'Buckets' and 'Values' with two templates Bucket and Value, 'Bucket' renders a sub template 'Value'. Value is being updated every second by the server.
The Bucket template has two dropdowns which I'm keeping state in the corresponding Bucket model.
The problem I have is in firefox everytime I change a dropdown it saves the state but doesn't reflect the change in the template it instead goes to the last item in the dropdown list. If I refresh the state is reflected correctly.
I can fix it by creating a third collection called 'states' and save the dropdown states there with a corresponding reference back to the Bucket but would be nice not to have to do this.
Any ideas would be great.
Dropdowns are among the input elements that don't work quite right on 0.5.2. There is currently a fix for this on the devel branch; you can either hang tight for a release, take your chances living on the edge, or find a workaround like putting your input element in a {{#constant}}{{/constant}} region.

Replace "Loading..." message in ListFragment when list is empty

I have two ListFragments next to each other.
The left one shows categories to be selected while the right on shows the elements in the selected category.
Now at the very start of the screen the left ListFragment shows all categories while the right one is empty and waits for a category to be selected. Only then it can display the memebers of the selected categry.
While it's empty however, the "Loading.." message gets display - which I think looks quite good.
All I like to do now is replace the "Loading..." text by my own.
Is this possible without having to implement the complete ListFragment class?
Many thanks.
ListFragment.setEmptyText(..) should do the trick!
The method setEmptyText shows a TextView when the list is empty therefore "Loading..." will not be shown. From Documentation
The default content for a ListFragment has a TextView that can be
shown when the list is empty. If you would like to have it shown, call
this method to supply the text it should use.
whereas spinning loading animation is an indeterminant progress indicator and is normally shown as per the docs
public void setListShown (boolean shown)
Since: API Level 11 Control whether the list is being displayed. You
can make it not displayed if you are waiting for the initial data to
show in it. During this time an indeterminant progress indicator will
be shown instead.
Applications do not normally need to use this themselves. The default
behavior of ListFragment is to start with the list not being shown,
only showing it once an adapter is given with
setListAdapter(ListAdapter). If the list at that point had not been
shown, when it does get shown it will be do without the user ever
seeing the hidden state.
Parameters shown If true, the list view is shown; if false, the
progress indicator. The initial value is true.

Resources