Add row in the middle of Datatable
Hi
my requirement is i've to display a table in following fashion:
Product_catagory product_name Price
cat1 p1 10
p2 10
p3 20
Sub_Total 40
cat2 p4 15
p5 10
Sub_Total 25
cat3 p33 10
Sub_Total 10how can i achieve the Sub_total display...
Thanks in advance
Fareen
<h:column>
<h:outputText value="#{product.name}" />
<br />
Subtotal
</h:column>
<h:column>
<h:outputText value="#{product.price}" />
<br />
<h:outputText value="#{bean.subtotal}" />
</h:column>or so.
You can also use a <h:panelGrid column="1"> here, but that renders another table in a table. You can also use plain vanilla HTML with c:forEach here if you're using at least JSF 1.2.
Similar Messages
-
I'm making a huge form in LiveCycle Designer. I want to be able to add rows in the middle o the table but in a way that the content below will move down automatically in a way it doe's in Word for example.
Sometimes I am adding a very high new row in the middle of a page and I want the content in the below rows to be moved to another page and if it is necessary I want a new page to be automatically created on the bottom of a document or something.
Is this possible or do I have to move everything by hand if I add new row to a table?If you are adding the rows at the runtime by clicking a button, then you have to use the instance Manager to add rows.. It will add rows at the end and then you need to write code to move the row at the desired location by using the moveInstance method of the instanceManager.
If you are adding a row at the design time, then you can right clcik the row and choose to add rows below.
Thanks
Srini -
How to add A single row at the middle of the table in a Webi report
Hi,
I created a Webi report using Universe(Created universe using bex query).Now i have a requirement to display a row at the middle of a report. Can you please tell me ,how to add a sigle row at the middle of a Webi report.
Thanks in advance
Regards
MonikaHi Monika,
It is not really possible to add a row (I assume you mean of unrelated data) to the middle of a table in a report. You can add a new table with a single row between two tables. For instance you could add a new one row table, or even single cells which are positioned relatively between two tables. Possibly a block on top of another. But this gets tricky.
Can you explain in more detail what you are trying to do?
Thanks -
How to insert a new row in the middle of an set of rows
Hi
How to insert a new row in the middle of an set of rows ? and How to Reset the line id after the new row added ?
Regards,
Sudhir B.Hai,
just try this,
Instead of using omatrix.Addrow(1,-1) use like
omatrix.AddRow( RowCount , Position)
RowCount
The number of rows to add (default is 1)
Position
The position of the new rows (0-based; default is -1, meaning append row to the end)
After adding rows in matrix For, sno.
for i=1 to omatrix.visualrowcount
otext=omatrix.getcellspecific("columnid",i) '--where columnid is the unique id of the sno column
otext.value=i
next i
Hope this helps you.
Thanks & Regards,
Parvatha Solai.N -
I'm trying to figure out how to insert rows in the middle
row 1
row 2
row 3
I need to insert 2 rows before row 2
I know I have to use the AddRow(1, Position) however after many tries, it doesn't seem to work or at least I don't know how to
insert the second row as if I do +1 it's not realy adequate, also, pVal.Row reports Row 2 and in the documentation it sais 0 based which is not right so I'm a bit confused on how to go about that.
Edited by: Marc Roussel on Aug 10, 2011 8:23 AM
Here's the whole thing, maybe you'll understand where I'm at :
I enter an ItemCode which is a kit. After the person enter the quantity, I pop a .NET Windows form which asks for questions and then after the questions I get back and add the lines but it seems that when I add the lines, I'm still on the line I was entering the kit and it overrides it instead of Adding the new row at the position I'm asking it to add the row.
Even if I do pVal.Row +1 or +2 or +3, it doesn't matter
Edited by: Marc Roussel on Aug 10, 2011 8:28 AMThe code below adds the 2 lines all right but then, a blank line after and the line that was already there below is destroyed. Don't ask me why and what is happening to that existing line which seems to have lost the ItemCode or I don't know what happened
CurrentLine = pVal.Row;
CurrentLine++;
oMatrix.AddRow(1, CurrentLine);
SAP.SetCellValue(oMatrix, SAPFramework.Enums.MARKETING_COLS.B1_ITEMCODE, CurrentLine, "01P38");
SAP.SetCellValue(oMatrix, "U_KitSeq", CurrentLine, NewKitSeq);
CurrentLine++;
oMatrix.AddRow(1, CurrentLine);
SAP.SetCellValue(oMatrix, SAPFramework.Enums.MARKETING_COLS.B1_ITEMCODE, CurrentLine, "03P12");
SAP.SetCellValue(oMatrix, "U_KitSeq", CurrentLine, NewKitSeq);
I did not know that doing a simple thing like this would be a hard business...
Edited by: Marc Roussel on Aug 10, 2011 9:15 AM -
Add row counter in output for datatable
How would one add a row counter on the output of a datatable component.
The datatable will be populated from a database resultset
The out put should be as follows
1 data columns .......
2 data columns .......
3 data columns ........
<h:dataTable value="#{register.newregistrations}" var="payment">
<h:column>
<h:outputText value="#{payment.counter}"> <<<< what can I replace this with ????
</h:outputText>
</h:column>
<h:column>
<h:outputText value="#{payment.expiry_date}">
</h:outputText>
</h:column>
</h:dataTable>
How do I create the row counter .The Following post is a solution
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=549084 -
How to add rows in the multicolumn listbox
hello all,
the questions are as below:
1. how to add the rows in the multicolumn listbox?
2. the message is RS232 communication message with hex format, how to convert the 2D format to adapt the itemnames property?
does anyboady can provide a simple example? thanks a lot.
Solved!
Go to Solution.Hello muks,
I would like to come up with the function like below picture:
the multicolumn listbox include 5 columns, the fifth column is hex format. I want to add the row one by one after each cycle, meanwhile there's a button that can clear the contents in the multicolumn listbox.
So the challenge for me is how to concatenate the different format into one array. then how to insert the row one by one.
Thanks in advance. -
JTable add row as the first row problem?
table.addRow();
i want it show on the first row
how to do?JTable doesn't have an addRow() method. Add add data to the TableModel not the table.
The DefaultTableModel has addRow() and insertRow() methods. -
How do I select a row from the middle of a recordset?
UserID QuestionID Answered
10 9 N
10 8 N
10 7 N
10 6 N
10 5 Y
10 4 Y
10 1 Y
From the table sorted by QuestionID DESC, how do I select the first row from the bottom going up with Answered value equal to 'N'?
Which in the example above would be:
10 6 N
I need to select this row and get the QuestionID value equal to 6.
Right now I have:
select QuestionID
from tblMap
where Answered = 'N'
and ROWNUM = 1
order by QuestionID ASC;
This always the top most row, which would be:
10 9 NHere i used DUAL to generate a list of numbers for me.
ME_XE?select *
2 from
3 (
4 select row_number() over (order by col1 desc) as rn, count(*) over() as cnt, col1
5 from
6 (
7 select level as col1 from dual connect by level <= 9
8 )
9 )
10 where ceil(cnt/2) = rn
11 /
RN CNT COL1
5 9 5
1 row selected.
Elapsed: 00:00:00.07
ME_XE?Edited by: Tubby on Jul 8, 2009 1:47 PM
Seems i misread the question :) -
Hi,
can i add row in the middle of the data table, not append (in the last of table)
Thanks
WalidHi!
Function appendRow(RowKey row) appends row to the end. Unfortunately function insertRow(RowKey row) is not implemented in standard cachedRowSetDataProvider, but You can extend cachedRowSetDataProvider and implement this function.
Then in you application You should call setCursorRow(RowKey row) and then insertRow(RowKey row).
Thanks,
Roman. -
Is it possible to have a button that will insert a table row rather than add it to the end?
I have an add row button that works correctly using addinstance, but I would like to have the add row button at the end of each row so a user could insert a row into the middle of existing/fiilled out rows. Is this possible? I would like to be able to do this using Formcalc as that is what all of my scripting in the form currently is.
Hi,
Yes, it is possible, but in effect what the script does is add a new row at the end of the table AND then move the row up to the approrpiate position.
See the examples here: http://assure.ly/gk8Q7a. Table 5 is a Table object, whereas Table 6 is built using subforms. In both cases the Index number is a button, that adds a row below the existing one clicked.
See does that help,
Niall -
How can I add a page or pages in the MIDDLE of a photo book I'm making?
I found some photos I want to put in a page in the middle of a photo book that I'm making, not at the end. Is there a way to add pages in the middle of the book?
Add the page using the "Add Page" button - it will appear at the end of the book. In "All Pages" view simply drag it between the pages, where you want it to appear.
-
How to add new row at the top of the advance table.
Hi,
I have one advanced table.
I want to add new rows in advanced table. I can able to add rows using the AddMoreRows button in the footer of the advanced table.
This adds the row at the end. But I want to add the row at the top.
How to achive this? Please suggest.
Thanks & Regards,
RajaHi,
Yes you can do it...
Just set the add Rows automatically property to False of Add Row Button
and then in processForm Request capture the addRows event
and invoke a method in AM and then create a new Row in VO.
Use this code...it will insert row at the top...
if("addRows".equals(event))
am.invokeMethod("addrows");
public void addrows()
AddressesVOImpl vo1 = getAddressesVO1();
AddressesVORowImpl row1 = (AddressesVORowImpl)vo1.createRow();
vo1.insertRowAtRangeIndex(0,row1);
vo1.setCurrentRow(row1);
Thanks,
Gaurav -
Add rows and sort JTable in the same program
I would like to have a button to add rows to the JTable, but would also like to sort the data within the columns. This program can sort the data prior to clicking the 'add row' button. After I click the button, there is no new row, and I lose the ability to sort the column. Do you have any tips or advice as to what I can do to fix my program? Is it because I have to have the final code for SortFilterModel to work?
Thanks
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class TableRowColumn extends JFrame
private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
JTable table;
DefaultTableModel model;
JPanel buttonPanel;
JButton button;
public TableRowColumn()
Object[][] data = {
{"6", "K"},
{"5", "A"},
{"1", "Z"}
String[] columnNames = {
"Number",
"Letter"
model = new DefaultTableModel(data, columnNames);
//comment out this SortFilterModel line
final SortFilterModel sorter = new SortFilterModel(model);
//Change sorter to model
table = new JTable(sorter);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
// Add table and a Button panel to the frame
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
button = new JButton( "Add Row" );
buttonPanel.add( button );
button.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent e)
model.addRow( createRow() );
int row = table.getRowCount() - 1;
table.changeSelection(row, row, false, false);
table.requestFocusInWindow();
//Set up double click handler for column headers and sort
table.getTableHeader().addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent event)
//check for click
if (event.getClickCount() < 2) return;
//find column of click and
int tableColumn = table.columnAtPoint(event.getPoint());
//translate to table model index and sort
int modelColumn = table.convertColumnIndexToModel(tableColumn);
sorter.sort(modelColumn);
private Object[] createRow()
Object[] newRow = new Object[2];
int row = table.getRowCount() + 1;
newRow[0] = Integer.toString( row );
newRow[1] = LETTERS.substring(row-1, row);
return newRow;
public static void main(String[] args)
TableRowColumn frame = new TableRowColumn();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}I attempted to modify the code in the correct way, but I ran into a problem near the bottom with the model.addRow(rowData); line. It has an error saying it can't find the addRow method. If I take away the model part, it will compile, but it will cause an infinite loop when I push the 'Add Row' button within the program. I didn't expect that to work, and I think it isn't calling the right model.
I am aware that my code organization and design skills are not very good. I am a fan of basic assembly and low-level hardware languages for the most part.
Thanks for your advice so far, it has been helpful.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class TableRowColumn extends JFrame
private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
JTable table;
public DefaultTableModel model;
JPanel buttonPanel;
JButton button;
public TableRowColumn()
Object[][] data = {
{"9", "C"},
{"5", "A"},
{"3", "B"}
String[] columnNames = {
"Number",
"Letter"
model = new DefaultTableModel(data, columnNames);
//comment out this SortFilterModel line
final SortFilterModel sorter = new SortFilterModel(model);
//Change sorter to model
table = new JTable(sorter);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
// Add table and a Button panel to the frame
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
button = new JButton( "Add Row" );
buttonPanel.add( button );
button.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent e)
sorter.addRow( createRow() );
int row = table.getRowCount() - 1;
table.changeSelection(row, row, false, false);
table.requestFocusInWindow();
//Set up double click handler for column headers and sort
table.getTableHeader().addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent event)
//check for click
if (event.getClickCount() < 2) return;
//find column of click and
int tableColumn = table.columnAtPoint(event.getPoint());
//translate to table model index and sort
int modelColumn = table.convertColumnIndexToModel(tableColumn);
sorter.sort(modelColumn);
private Object[] createRow()
Object[] newRow = new Object[2];
int row = table.getRowCount() + 1;
newRow[0] = Integer.toString( row );
newRow[1] = LETTERS.substring(row-1, row);
return newRow;
public static void main(String[] args)
TableRowColumn frame = new TableRowColumn();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
class SortFilterModel extends AbstractTableModel{
public SortFilterModel(TableModel m){
model = m;
rows = new Row[model.getRowCount()];
for (int i = 0; i < rows.length; i++) {
rows[i] = new Row();
rows.index = i;
public void sort(int c){
sortColumn = c;
Arrays.sort(rows);
fireTableDataChanged();
public Object getValueAt(int r, int c) {
return model.getValueAt(rows[r].index, c);
public boolean isCellEditable(int r, int c){
return model.isCellEditable(rows[r].index, c);
public void setValueAt(Object aValue, int r, int c){
model.setValueAt(aValue, rows[r].index, c);
public int getRowCount() {
return model.getRowCount();
public int getColumnCount(){
return model.getColumnCount();
public String getColumnName(int c) {
return model.getColumnName(c);
public Class getColumnClass(int c){
return model.getColumnClass(c);
private class Row implements Comparable {
public int index;
public int compareTo(Object other) {
Row otherRow = (Row)other;
Object a = model.getValueAt(index, sortColumn);
Object b = model.getValueAt(otherRow.index, sortColumn);
if (a instanceof Comparable) {
return ((Comparable)a).compareTo(b);
else{
return a.toString().compareTo(b.toString());
public void addRow(Object[] rowData) {
Row[] oldRows = new Row[rows.length];
for (int i=0; i<rows.length; i++) {
oldRows[i] = rows[i];
rows = new Row[rows.length +1];
for (int i=0; i < oldRows.length; i++) {
rows[i] = oldRows[i];
rows[oldRows.length] = new Row();
rows[oldRows.length].index = oldRows.length;
addRow (rowData);
//model.addRow(rowData);
fireTableDataChanged();
private TableModel model;
private int sortColumn;
private Row[] rows; -
How to add an extra row at the end of the Grid?
Hi gurus,
I am getting result from the select query which has 4 columns.
I got the requirement to display the sum of those columns as the last row.
How can i add the another row at the end of the iGrid ?
Data would look like
Sno Col1 Col2 Col3 Col4
1 4 6 1 6
2 5 8 0 8
3 6 1 2 5
Sum 15 14 3 19
Do i have to add transformation to the sql query? or
Can i add row to the display tempalate by accessing the Gridobject?
Please help.
Thanks
Vansi
Edited by: vamsi P on Feb 12, 2008 8:49 PM
Edited by: vamsi P on Feb 12, 2008 8:49 PMHi Vamsi,
There are a few options ...
1) The one suggested by Prasanna
2) Loop through all rows via JavaScript and use the GridObject methods to set cell values and then perform an applet.refreshGrid( false )
3) Apply an Inline transform
4) Use a stored procedure to return the results and the totals as one recordset.
The stored procedure would be the fastest for runtime.
The Iniline XSL transform would be the second fastest. If you specify the XSL in a generic way, you may even be able to reuse it in other scenarios. If you hardcode the fields in the XSL, it would be a matter of simple code adjustment when you encounter a similar scenario.
Hope this helps.
Cheers,
Jai.
Maybe you are looking for
-
PASSWORD FOR FLODERS PLEAse HELP URGENT
HI ALL please tell me the method of implementing password provision for some folders/files in the system. it should ask for password authentification before opening when i click on the folder. please help urgent thanks belur
-
I am in the middle of implementation of Travel Management and I have need few clarification. I request you please provide your input on the below issue. 1) Is it possible to attach scanned copies of receipt as an attachment to each expense type.
-
No rounding with rounding profil when conversion Roundg Unit Purch Unit
Hello, I have a trouble when I try to make a purchase order with a material which has this data: Base unit ST Purchase unit on info record : CAR Rouding profil on info record : only with unit PAQ (%+ 50 ; %-50) Variable purchase order unit : 1 active
-
Good day master's! I'm having a so slow query with this code: SELECT EBELN BELNR AUGBL GJAHR KOSTL INTO TABLE IT_BSEG FROM BSEG WHERE EBELN EQ LS_EKKO-EBELN AND BUKRS EQ S_BUKRS. I use ABAP debugger and found out the cause why my program are so slow.
-
Dynamic hyperlink runs executable with parameter
Hi I have created a BI template for the Final Payment Register report in EBS Payables. We have a requirement to provide a link in the report next to each invoice so that users can view a scan of the invoice stored in a LONG RAW column from a third-pa