Hiding Birt columns dynamically - java

I am trying to display the no of players and best players statistics in a country for specific games in a report
Need to modify the cross tab to show only statistics of the football.How to hide the cross tab column when name of the game(column) is "cricket".
I don't want to achieve this using filters in data sets or by adding condition in where clause of the query.

Related

Adempiere Hiding / Showing Field Based on tick mark checked or unchecked in client widnow by using display logic

I am working with adempiere, I would like to Hide/Show field of a window based on tick mark available in another window Client which is (AD_Clinet table). E.g. I created barcode field in Material Receipt window which i would like to show only when Client screen Scan Barcode On Material Receipt is tick marked. I am using Display logic of window Tab Field > Tab > Field ,following things are tried by me
AD_Client.Is_ScanBarcodeMaterialReceiot
Barcode_Field= #SELECT Is_ScanBarcodeMaterialReceiot FROM AD_Client WHERE AD_Client_ID=##AD_Client_ID##
#Barcode_Field=AD_Client.Is_ScanBarcodeMaterialReceiot#
I didn't got proper output for that.
Please provide suggessions to solve out this problem.
The display logic in ADempiere does not support sql statements. You can use the SQL in a virtual column and then reference that column in your display logic.
So add a Yes/No virtual column to the table with the sql value set to
SELECT AD_Client.Is_ScanBarcodeMaterialReceipt FROM AD_Client WHERE AD_Client_ID=##AD_Client_ID#
Call this column by the same name Is_ScanBarcodeMaterialReceipt. Add it to the window/tab but don't display it. The value should appear in the context when you open the window.
Then you can set your display logic on the bar code field to
#Is_ScanBarcodeMaterialReceipt#=Y

How to get the top 10 value in BIRT

I have a trouble that I need to get the top 10 busiest stations, right now, I have these columns (number of buses, datetime, station name). Now, I can dynamically change the time range based on user's selection. But, the BIRT just show all the stations' name in one chart. How can I get the top 10 stations' name? I tried to add filter in my chart, but after I added it, it only showed one station name. Can anyone help me solve my problem? (In my chart, the X-axis is the station name, and Y-axis is the number of buses)
This is probably because stations data are aggregated on-the-fly in the chart view, whereas the top 10 filter you added is filtering on details rows before aggregation. As far as i know we can't specify that a chart filter should be applied at a group level such as we can do it with a table element.
Therefore you should aggregate data before rendering the chart. There are a couple of ways to do this:
Aggregate data in your dataset (SQL group by, ...)
Aggregate in a hidden birt table element with groups, and base the chart on this table. Notice in this case the top 10 filter has to be defined in the table element
Aggregate using a datacube, and base the chart on this datacube or a crosstab
If you cant't make it work as expected, for this kind of issue you should post a .rptdesign based on "Classic models" database sample.

Java Checkbox List in Netbeans

I have to design an application which handles customer orders. The GUI has tabs, one for the customer and one for the admin. In the customer tab, he has the possibility of submitting an order, by chosing the products from the product list, each having a checkbox in front of them and a text field in which the quantity will be specified.
I am using the netbeans gui editor for the design and I am a bit stuck as the code cannot be modified. I cannot create the product list dynamically (so to create a line for each product in the product array list, and on each line to put the checkbox and the textfield) or at least I don't know how to.
My question is - is there any way of dynamically creating such a list (checkbox + label with the product name + textfield which waits for the quantity) or is there an alternative to my idea ?
Sounds like you need to use a JTable for your list of Products and Quantities. In the NetBeans GUI editor you will only be able to place the JTable on the panel you are designing. After that you need to define a 'Model' for your table which will hold the data you are entering. See the official Oracle Java tutorial on How to Use Tables.
Of course there are lots of other use cases that would fit your requirements, but your design sounds fine. The checkbox is probably superfluous though, as entering a quantity against a product should be enough to indicate that the customer has chosen that Product. If your list of Products gets too long, though, you might want to re-visit this design. Perhaps the table could have 2 coulmns, the first one being a combo-box list of Products, and the second column has the quantity.

Binding database column to java jComboBox and JList

Ok, say I have a database table with two columns - one "Name", the other "Age", and there are over 40 names and their respective ages in the table. I want these names to be listed out in a jList/jComboBox, and also I want to be able to click on a name in the jList/jComboBox and have its respective age appear in - say - a text box. Do I have to go about this by simply writing a code that selects all the names from the table and populates the jList/jComboBox and then another code that takes the selected name, puts it in an sql statement, finds the matching age and sends it to a text box, OR is there some kind of a VB-esque column-to-comboBox/List-binding that I can utilise to go about this?
For only 40 name-age combinations, I would just query the database once, and store this information in a Map. Then you can just query the map when a name is selected, and update the age textfield. This will go a lot faster then running SQL queries each time the selection has been changed.
You have to set Model for your swing elements and for updating data based on changes at one place to other implement Listeners.
Have a look at this
Binding comboboxes in swing
Create a custom object that stores both the name and age values and add this object to the combobox. Then when you select an item you have access to both values.
For example: How to use Map element as text of a JComboBox

JTable: how to select columns at runtime

I have too many columns in a table to display them all at once, and would like to let the user change which columns are visible. How can I do this?
note: It is easy to make the application select columns at runtime. What I am asking is what UI element(s) to add to allow the user to hide/unhide columns at runtime.
If you can import some external libraries, you could have a look to
http://swinglabs.org/docs/components/JXTable/tutorial.jsp which supports such runtime modifications.
Table Column Manager allows the user to right click on the table header to control which columns are visible.
There isn't a standard way, however what you could do is something like this:
Use a custom table header render component to install additional actions/UI on the column headers (e.g. through a context menu of checkboxes)
Add a custom model which you can re-configure to display different items depending on what the user selected through additional actions on the column headers
Do the event wiring/plumbing.
Alternatively: find a custom component that does this. There probably is something out there already: projects like the component library from JIDE would be a good place to look.
Use TableModel.addColumn(TableColumn) and TableModel.removeColumn(TableColumn) methods to show/hide columns on-the-fly.
You can attach that calls to any other GUI components (for example, make a JPanel or a JTable with a few checkboxes).
Either display a popup menu with the possible columns when user right-clicks the header or implement a small (and light) popup dialog with a checkbox list for selecting the visible columns. The dialog can be opened by right-clicking, by clicking a toolbar button or from a toolbar menu.

Categories