Sum of two columns of Jtable in Jclient (summarized columns)

I want to display the sum of two columns of Jtable in a text box, just as we use to do in Forms developer.
How is this possible in Jclient.
I would be glad if someone can give a detail info about it.

Actually I wanted to sum the values of a column when a user enters a value in the Jtable when a new record is created. before it is commited
That summarized value which I want in the textbox will then be used in the validation rule.

Similar Messages

  • Detecting clicked column in JTable (with JCheckBox in column)

    I am struggling with something that seems like it should be so simple, but it doesn't work as I expect;
    I have a table with 5 columns, the 5th column is a CheckBox. What I need to do is detect when the 5th column changes, ie. the check box is clicked;
    If I use a MouseListener on the table, and derive the table from the event, the column that I get back from getSelectedColumn() is -1, which is not conclusive. I assume this is because clicking the check box is not actually selecting the column.
    I implemented a TableModelListener as follow;
    tableModel.addTableModelListener(new TableModelListener()
    public void tableChanged(TableModelEvent e)
    System.out.println("Changed Column is " + e.getColumn() + " " + e.getFirstRow());
    This seems to do the same as before, and gives a first row of 0 and selected column of -1. Once again inconclusive.
    The cell as I say is rendered as a JCheckBox, the data in the table model obviously being Boolean.
    Can anyone suggest how I can determine if my column with a Check Box in has been clicked, and if so, which Row? (I have thought about overriding JCheckBox, but this seems more work than necessary)
    Thanks in anticipation

    You need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html]
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on
    the information provided.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting] so the posted code retains its original formatting.

  • How do you get the sum of two columns multipied together?

    I can't seem to figure out how to get the sum of two columns multiplied together without having to manually type out each location (example: A1*B1+A2*B2+A3*B3, etc..).  Though the idea seems to be rather simple, everything I have tried has only given me an error.  I know there must be an easier way of doing this, but I get lost in the explanations given in 'help' area of numbers, can someone help me?

    C3=SUMPRODUCT(A3:A18, B3:B18)
    the function SUMPRODUCT() takes ranges and multiplies corresponding cells in the ranges, then adds them together.
    I the case I show SUMPRODUCT() performs:
    A3*B3 + A4*B4 + A5*B5 + A6*B6 + ... +  A18*B18
    If you want to perform the same operation on the whole column (s) you could modify the formula:
    C3=SUMPRODUCT(A, B)

  • Compute sum of two columns - display result in the third column

    Hello,
    I have a report and I want to compute sum of two report columns and display the total in the third column.
    For example: Sample_My_Report
    Col1 Col2 Total (Col1+Col2)
    3 7 10
    can anyone help me out with this issue.
    thanks.

    thanks for replying. One more thing is that
    How can I compute Avg for a particular column in a Master detail report. I need the avg(sal) to be displayed at the end of the report similar to sum(reports total).
    Can you help me out with this issue.
    thanks.

  • Sum of two columns

    Hi guys
    i need to insert one column in a row with forumla as col1+col2. how can i do that in simple tabular report. My two columns in XML are like this:-
    <T_AMT>240.6</T_AMT>
    <TAX_AMT>0</TAX_AMT>
    Can i use substring function while creating template in word or i need to use substring while writing query...
    thanks
    Edited by: ObieeUser on 28-May-2010 03:07

    Hi Vetsrini
    thanks for your reply...
    for showing sum of two columns:-
    is it possible to do with GUI instead of writing code or doing tweaks in the sql... the main drawback of doing tweaks in sql is after i make changed in sql and then i click on sql builder it doesn't show me the changes which i have done....
    Use of Substr/Decode/Case When or other oracle function
    another question is like if i need to use substr function in sql can't i do it in SQL builder if yes then how as i have seen function drop down in sql builder but it doesn't show such function?
    regards

  • Two dimension in JTable

    Hi,
    Can anyone tell me how to write two dimension in JTable?1 row for title and 1 column for another title.
    Another question is,how to write JTable in a report format,such as few columns for expenses and at the end a total for the whole expenses.How to add the total at the end of the table?
    Thanks for any help.

    1. Are you saying you want a JTable which has both a row header and column header?
    2. You'll need to use the Calendar class to determine the appropriate day of the week given a Date object. As so:
    Calendar cal = Calendar.getInstance();
    cal.setTime(myDate);
    int dayOfWeek = cal.get(Calendar.DAY OF WEEK);
    String[] daysOfWeek = DateFormatSymbols.getDaysOfWeek();
    String dayOfWeekStr = daysOfWeek[dayOfWeek];PS: There is a lot in Java that people don't know about. Make sure you download the Java API source, as well. I had trouble figuring out how to convert the int day to a String day, so I went into the source for SimpleDateFormat to figure out how it does it...and I find another useful Java class in DateFormatSymbols.

  • Two dimension in JTable and date.

    Hi,
    Can anyone show me or teach me how to create two dimension in JTable.
    The column is time ie 12pm-1pm, 1pm-2pm.......3am-4am, and the row is monday, tuesday .....sunday.And row should consists of day and date ie monday 1/4,tuesday 2/4.....sunday 8/4.
    Thanks for any help.

    Hi,
    You cannot automatically filter members using a mapping based on the smart list. To do that work, i recommend using an UDA (User Defined Attribute) or create an attribute dimension associated to your employee dimension.
    Regards,
    David Mendele
    BI / EPM Project manager at Business & Decision
    Lima, Peru

  • Scroll Fix Column in JTable

    I have see a lots of examples of whow to create fix column into JTable.
    But all the examples have the same problems.
    When I wont to scroll over the fix column the vertical scroll bar of the no fix column dont move, so the no fix column dose not move and the fix columns and no fix columns aren?t alined.
    If sameone have same example, send it please !!!!
    Thanks !!!
    Pablo

    In a recent project I've had the same problem.
    After a long research at the Swing forum at java.sun.org and google I found out that
    1. Currently there is no proper Open Source solution
    2. All the postings at sun are good concepts, but far away from solutions
    3. The only (for me )acceptable commercial solution is the JCTable from Quest (formerly KGroup)
    Since I want to have full control over the source code of the table, I decided to collect all the tips from this forums and write my own table.
    Here is a first try:
    http://jroller.com/resources/kriede/CoolTable.java
    The main idea is to have two tables, one for the locked columns (= fixed columns = frozen columns) and one for the scrollable columns. With all the tips from this forum it was more or less a puzzle to make it work pretty.

  • JTable: Selecting rows in columns independently

    Dear all,
    I have a JTable with two columns. I want the user to be able to select cells in columns independently. At present, the entire row gets marked as selected. Is it possible at all to, for instance, select row1 1 to 3 in column 1 and rows 4 to 5 in column 2? If so, where's the switch? Thanks a lot in advance!
    Cheers,
    Martin

    Are you trying to use a seperate table for each column.
    Thats not a good idear.
    Here is what you have to do.
    1. Create a sub class of JTable
    2. You will have to redefine how the selection is done so. You will need some sort of a collection to store the list of selected cells indexes
    2.1 Selecting a cell is simply adding the coordinations of the cell to the selection
    2.2 de selecting is just removing it from the collection.
    2.3 Here is what you have to override
         setColumnSelectionInterval()
         setColumnSelectionInterval()
         changeSelection()
         selectAll()
         getSelectedColumns()
         getSelectedColumn()
         getSelectedRows()
         getSelectedRow() You migh also need few new methods such as
         setCellSelected(int row, int column, boolean selected);
         boolean isCellSelected(int row, int column);
         clearSelection();
         int[][] getSelectedCells();You will have to implement the above in terms of your new data structure.
    3. Handle mouse events.
    Ex:- when user cicks on a cell if it is already selected it should be deselected (see 2.2)
    other wise current selected should be cleared and the clicked cell should be selected
    if your has pressed CTRL key while clicking the the cell should be selected without deselecting the old selection.
    ---you can use above using a MouseListener
    When the user hold down a button and move the mouse accross multiple cell those need to be selected.
    --- You will need a MouseMotionListener for this
    You might also need to allow selection using key bord. You can do that using a KeyListener
    4. Displaying the selection
    You have to make sure only the selected cells are high lighted on the table.
    You can do this using a simple trick.
    (Just override getCellEditor(int row, int column) and getCellRenderer(int row, int column) )
    Here is what you should do in getCellRenderer(int row, int column)
    public TableCellRenderer getCellRenderer(int row, int column)
      TableCellRenderer realRenderer = super.getCellRenderer(int row, int);
      return new WrapperRenderer(realRenderer,selectedCellsCollection.isCellSelected(row,column));
    static class WrapperRenderer implements TableCellRenderer{
        TableCellRenderer realRenderer;
        boolean selected;
        public WrapperRenderer(TableCellRenderer realRenderer, boolean selected){
           this.realRenderer = realRenderer;
           this.selected = selected;
        public Component getTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column){       
            return realRenderer.getTableCellRendererComponent(table,value,selected,hasFocus,row,column);
    }What the above code does is it simply created wrapper for the Renderer and when generating the rendering component it replaces the isSeleted flag with our on selected flag
    and the original renderer taken from the super class will do the rest.
    You will have to do the same with the TableCellEditor.
    By the way dont use above code as it is becouse the getCellRenderer method create a new instance of WrapperRenderer every time.
    If the table has 10000 cells above will create 10000 instances. So you should refine above code.
    5. Finnaly.
    Every time the selection is changes you should make the table rerender the respective cells in or der to make the changes visible.
    I'll leave that part for you to figure out.
    A Final word
    When implementing th above make sure that you do it in the java way of doing it.
    For the collection of selected cells write following classes
    TableCellSelectionModel  // and interface which define what it does
    DefaultTableCellSelectionModel //Your own implementation of above interface the table you create should use thisby default
    //To communicate the selection changes
    TableCellSelectionModelListener
    TableCellSelectionModelEventif you read the javadoc about similer classes in ListSelectionModel you will get an idear
    But dont make it as complex as ListSelectionModel try to keep the number of methods less than 5.
    If you want to make it completly genaric you will have to resolve some issues such as handling changes to the table model.
    Ex:- Rows and colums can be added and removed in the TableModle at the run time as a result the row and column indexes of some cells might change
    and the TableCellSelectionModel should be updated with those changes.
    Even though the todo list is quite long if you plan your implementation properly the code will not be that long.
    And more importantly you will learn lots more by trying to implementing this.
    Happy Coding :)

  • I want to show sum of two measures in Crosstab, is it possible?

    Hello,
    I want to show sum of two measures in Crosstab. There are only two measures in BW query, and I want to show sum of them by new column in Crosstab component.
    For example:
    Measure 1
    Measure 2
    Sum (New Column)
    100
    200
    300
    50
    30
    80
    30
    90
    80
    Is it possible ?
    Thanks.

    Hi,
    Design Studio is not capable to calculate that. If you like you can do it in BEx Query Designer as mentioned above.
    Alternatively you can open your Query in Analysis Office and do the calculation there. Then you can smart copy and paste the navigation state into Design Studio.
    Dirk

  • How to display two or more links in a single column

    Hi,
    Is there a way to display two links in a single column in a sql query report . I am able to specify one but I am not able to add links to the same column . I want to take the same column id and redirect the user to different pages based on the values selected .
    Thanks

    There is no way to this declaratively that I know of. Some alternatives...
    1. Put the conditional branching logic in the report SQL itself. e.g. case when ... then '< a href=..' else '< a href=...' end and make sure the column display type is Standard Report column
    2. Have the declarative column link go to a dummy/intermediate page and setup On Load: Before-Header branches on that page to redirect to the desired page based on the item value(s) passed in to the intermediate page.

  • How do I make a form field validate that it is the sum of two other fields?

    Hi there,
    I am creating a form, and I would like one of the fields to validate by making sure that this field is the sum of two other fields in the form.  Does anyone have any ideas on how to go about this?  I know I'll need to run a custom validation script, but I'm not sure where to begin - I've never done one for validation before.
    Thanks for any help!

    OK, here's a sample script that I hope will clearly demonstrate the general approach. It is intended to be the custom Validate script of the field that the user enters that value that is supposed to be equal to the sum of the two others.
    // Custom Validate script
    (function () {
        // Get the value that the user entered
        var sVal = event.value;
        // If it is blank, do nothing else
        if (!sVal) {
            return;
        // Convert string to a number
        nVal = +sVal;
        // Get the values of the fields, as numbers
        var v1 = +getField("text1").value;
        var v2 = +getField("text2").value;
        // Add them together, rounding to two decimal places, converting to number
        var sum = +util.printf("%.2f", v1 + v2);
        // Compare entered value to the sum of the other two fields
        // Alter the user if they do not match
        if (nVal !== sum) {
            app.alert("The value you entered does not equal the sum of text1 and text2. Please correct.", 3);
            // If you want the entered value rejected, include the following
            event.rc = false;
    Replace "text1" and "text2" with the actual field names.

  • Changing the size of column in JTable as per requirement

    I'm copying content of excel file into the JTable.
    But as the number of columns increases the size of columns get reduced.
    But i want the table of same column size for any number of columns in the table.
    If display area size is less then JTable must scroll according to the size.

    Scroll bars appear when the table's size is larger than the scrollpane's viewport. So your viewport is a fixed size. You adjust the size of the table to get the scrollbars to appear and get smaller (as the table's size increases).

  • Hiding a column in jtable made from DefaultTableModel.

    I have made my jtable from DefaultTableModel.
    I want to keep one column in the jtable as hidden storing some data containing neccessary information like the "path of the file"
    which need not be shown to the user.
    Please tell me how I can hide one column in the Jtable.
    please provide siome link or code for the same.
    Tia,
    Sarwa

    dayanandabv wrote:
    [http://search.sun.com/search/onesearch/index.jsp?qt=hide+column%2B+JTable&rfsubcat=&col=developer-forums]
    My thought exactly.
    db

  • Material description filled automatically as the sum of two fields

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

Maybe you are looking for