To enable or disable toggle button in Adempiere

For a view tab where data is required to be displayed in tabular (grid view) format, user may want the toggle button to be disabled. Form view may not be required since user only wants the data display and no changes to data.

Add a new column to the AD_Tab table in the database

ALTER TABLE ONLY ad_tab ADD COLUMN istoggleviewenabled CHARACTER(1) DEFAULT ‘Y’;

Modify the view AD_Tab_V – add the new field to the view (use create or replace)



t.ad_tab_id, t.ad_window_id, t.ad_table_id,,

t.description,, t.seqno, t.issinglerow, t.hastree,

t.isinfotab, tbl.replicationtype, tbl.tablename,

tbl.accesslevel, tbl.issecurityenabled, tbl.isdeleteable,

tbl.ishighvolume, tbl.isview, ‘N’::bpchar AS hasassociation,

t.istranslationtab, t.isreadonly, t.ad_image_id, t.tablevel,

t.whereclause, t.orderbyclause, t.commitwarning,

t.readonlylogic, t.displaylogic, t.ad_column_id,

t.ad_process_id, t.issorttab, t.isinsertrecord,

t.isadvancedtab, t.ad_columnsortorder_id,

t.ad_columnsortyesno_id, t.included_tab_id,

t.isattachmentenabled, t.istoggleviewenabled

FROM adempiere.ad_tab t

JOIN adempiere.ad_table tbl ON t.ad_table_id = tbl.ad_table_id

WHERE t.isactive = ‘Y’::bpchar

AND tbl.isactive = ‘Y’::bpchar;

Add the column in Adempiere application

Table and Column

You need to make following code changes:

1.       Add the field in GridTabVO

/** Field to enable/disable the toggle view */

public boolean isToggleViewEnabled = true

2. Add to the function – GridTabVO.loadTabDetails

vo.isToggleViewEnabled = rs.getString(“istoggleviewenabled”)


3. Add to the function – GridTabVO.clone

clone.isToggleViewEnabled = isToggleViewEnabled;

4. Add new function – GridTab


* Whether the toggle view button is enabled or not

* true – toolbar button should be enabled

* false – toolbar button should be disabled


* @return boolean


public boolean isToggleViewEnabled() {

return m_vo.isToggleViewEnabled;


5. To disable the button on the web client – Add the statement in the function – AbstractADWindowPanel.updateToolbar

toolbar.enableGridToggle(curTab.isToggleViewEnabled()); // Added to disable the toggle of view as per config

6.       To disable the button functionality in the Swing client – Add the statement in the function –


public void switchRowPresentation()


if (m_mTab.isToggleViewEnabled()) {

// Existing code here




With this change in place, you have a freedom of making a view available only as

1) Form View

2) Grid View or

3) Both – with toggle option


This is extremely useful when your customer asks you to provide you functionality like following

1) Create New Project

2) Existing Projects

3) Show document list for a project


If you notice properly

1) For the first scenario we need to see just Form view with the form open in edit mode. We don’t need a grid view and hence we don’t need to toggle the viewes.

2) In second case we need to be able to see both views

3) In third case we don’t need form view and hence toggle MUST not be allowed


Above enhancement will allow Adempiere developer to manage those scenario through configuration. This is the beauty of Adempiere.

Walking Tree is a leading provider of Adempiere training and consulting. If you want to avail our professional services then you can visit our contact us page for more detail.

Tagged with: , , ,
Posted in ADempiere

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: