Refresh a sibling tab

<<

Hari Madhavan

Posts: 51

Joined: Thu Jul 08, 2010 10:49 am

Post Fri May 04, 2012 4:50 pm

Refresh a sibling tab

Hi,

I have a situation where the changes in one tab impacts a field in a sibiling tab ( within the same window ) . The way I was planning to propagate the change to the other tab - was through the database.

However when the user moves to the other tab - the changes are visible only if it is the first time the tab is loaded ( as accessing the tab causes the load from the database).

Subsequent accesses do not show these changes unless the tab is refreshed. And worse, any attempt to update causes a stale data error.

Is there anyway I can clear out the tab instance that is loaded, so that it would reloaded if accessed again?

Regards
Hari
Hari Madhavan
Promantia Global Consulting LLP
<<

Posts: 29

Joined: Mon Nov 07, 2011 12:28 pm

Post Wed May 09, 2012 3:54 pm

Re: Refresh a sibling tab

Hi Hari,

The solution that you have used is correct, but the problem that you are having when the field is updated cannot be solved, because the OB framework is designed to work in that way.

It happens because each line has a field (updated) which stores the time of the last update.
When the value of the field is changed using your trigger the field "updated" is also updated with the new time of the last change.

When data is changed using the UI (tab), the OB framework checks that the value of the field "updated" has not changed since the record has been loaded. If it hasn't happens the record won't be updated.

Regards

Guillermo
<<

Hari Madhavan

Posts: 51

Joined: Thu Jul 08, 2010 10:49 am

Post Wed May 09, 2012 5:32 pm

Re: Refresh a sibling tab

Hi Guillermo,

Thanks for the explanations. Which leads me to thinking that there are two things that I could try to do ( though I do not know how ), to get around the issue. Both of which I feel could be done using smartclient API ( though I don't know how )
1) Get the tab that has been updated in the db to the state before when the tab was first clicked ( i.e data not bound to the tab )
2) Simulate a refresh on tab as soon as the tab is clicked so that the latest version of the data is loaded.

Any pointers would be helpful.


Regards
Hari
Hari Madhavan
Promantia Global Consulting LLP
<<

Posts: 29

Joined: Mon Nov 07, 2011 12:28 pm

Post Thu May 10, 2012 10:04 am

Re: Refresh a sibling tab

Hi Hari,

I think your second approach is better than first one.

Take a view of the smartclient API reference

You need to overload the tabSelected method to refresh the standard window when the tab is clicked in the tabset. Because OBTabSet extends from isc.TabSet you should overload the OBTabSet.tabSelected method. To overload you've to define a compenentProvider which will declare a new staticResource.

  Code:
  tabSelected: function (tabNum, tabPane, ID, tab) {
    var event = isc.EventHandler.getLastEvent();
    if (tabPane.refreshContents) {
      tabPane.doRefreshContents(true, true);
    }
    // if the event is a mouse event then let the item click not do max/min
    // tabselected events are also fired when drawing
    if (this.isDrawn() && event && isc.EventHandler.isMouseEvent(event.eventType) && tabPane.parentView && tabPane.parentView.state !== isc.OBStandardView.STATE_TOP_MAX && tabPane.parentView.state !== isc.OBStandardView.STATE_MID) {
      this.ignoreItemClick = true;
    }
  },


More info here:
http://wiki.openbravo.com/wiki/Openbrav ... t_Provider
This how to could be usefull for you to manage the component provider: http://wiki.openbravo.com/wiki/How_to_a ... he_toolbar

Regards,

Guillermo

Return to Developers

Who is online

Users browsing this forum: No registered users and 5 guests

cron
Website Terms


Designed by ST Software for PTF.