Sort JTable columns except one.
Hi.
I want make a sortable JTable, but I need to avoid the sorting by first column.
There is an easy way to do it ??
Thanks in advance
Is solved. Thanks anyway.
Message was edited by:
DiegoJ
hai,
be too specific. dont think that ur ques has to be short. type more about ur question and make us clear to clear ur doubt. please type how the record will be before ur program get executed and how the answer has to be after ur program has to be executed. that is show them as u showed the records before.
by
bvrk.
Similar Messages
-
Sorting JTable column with DefaultTableModel
Hi all,
can i sort the column in Jtable which is using the DefaultTableModel? If can, how? I have downlaad the TableSorter.java and implement it into my code which is using DefaultTablemodel, but it doesn't work... :(
If sort does not work with the DefaultTableModel, which model should i use that will list the records in the JTable and sort it?
Thanks in advance for yr help...When you create your own table model you usually extend the AbstractTableModel class, and the DefaultTableModel class does just the same.
So I think your problem is likely to be due to the sorter class itself, rather than the model.
I hope this will help you.
Bye -
Sorting records all except one and maintaining index
I have a mysql table with three attributes.
att1 | att2 | att3
1 | 0.1 | 0.2
2 | 0.4 | 0.3
3 | 0.2 | 0.1
4 | 0.3 | 0.5
Now through my program, I select one record according to attribute 2. Suppose in this case I select the value 0.2(from att2) and get the index. Now what I want to do is: sort descending(here is want to exclude index 3 since it has already been identified by the first part of the program) according to the rest values in att3. I want the corresponding index of of these values too.
Can anyone help plz.... I have tried to make the problem clear...In case of doubt please ask me..
Thanks in advance
Rakeshthanks..
i already solved it..
but thanks anyways....
its nice of u to ask -
I have a mysql table with three attributes.
att1 | att2 | att3
1 | 0.1 | 0.2
2 | 0.4 | 0.3
3 | 0.2 | 0.1
4 | 0.3 | 0.5
Now through my program, I select one record according to attribute 2. Suppose in this case I select the value 0.2(from att2) and get the index. Now what I want to do is: sort descending(here is want to exclude index 3 since it has already been identified by the first part of the program) according to the rest values in att3. I want the corresponding index of of these values too.
Can anyone help plz.... I have tried to make the problem clear...In case of doubt please ask me..
Thanks in advance
Rakeshhai,
be too specific. dont think that ur ques has to be short. type more about ur question and make us clear to clear ur doubt. please type how the record will be before ur program get executed and how the answer has to be after ur program has to be executed. that is show them as u showed the records before.
by
bvrk. -
I have set a sort order column on one of A VARCHAR field, but the functionality is not working. The sorting is enabled in the table view and when I sort by the said column it still sorts based on the VARCHAR values of the column instead of the other INT column I want to sort by. The logical SQL and physical query never even includes the column to sort. Are there any exceptions for the 'Sort Order Column' setting? Is there a config setting or data connections setting that I need to check to make this work?
Thank You!
Edited by: VNC on Oct 3, 2011 9:08 AMhi,
can you give me more detailes like some sample column data like below kind
Like Ex: varchar month column it sould display based on month id
month : Fev-2011,Dec-2011,jan-2011 and month id 1 to 12
set your month id as sort order column of month name.
double click month name ->In general tab set the sort order column as month id
FYI...see the sample link
http://www.biconsultinggroup.com/obiee-tips-and-tricks/setting-a-sort-order-column.html
i hope helped you
THanks
Deva
Edited by: Devarasu on Oct 4, 2011 12:39 AM -
Sorting blank column in jTable
Hi all,
I am having problem sorting blank columns.
I have already read thru [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting]
Using setAutoCreateRowSorter works except when sorting blank column as i want all blank column to be sorted to the bottom be it ascending or descending order.
I am using Comparator to do the sorting but how do I know when it is doing ascending or descending?
Edited by: zwseo on Jul 17, 2008 7:25 PMTableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this.dataTable.getModel());
Comparator<String> comparator = new Comparator<String>() {
public int compare(String s1, String s2) {
if (s1.compareTo(s2) == 0) { // same string
return s1.compareTo(s2);
} else {
if (s1.trim().equals("") && !s2.trim().equals("")) //string 1 is null
//if ascending, return positve
return s1.compareTo(s2);
//if decending, return negative
//return s2.compareTo(s1);
else if (!s1.trim().equals("") && s2.trim().equals("")) //string 2 is null
//if ascending, return negative
return s2.compareTo(s1);
//if decending, return positive
//return s1.compareTo(s2);
else {
return s1.compareTo(s2);
this.dataTable.setRowSorter(sorter);I am not sure whether i am doing this right.... please help me on the comments part... i do not know how to write that if statement. -
Can numbers sort by more than one column? How?
Can numbers sort by more than one column? How?
Open the "Sort & Filter" options:
Then add columns. You can set sort ASCENDING or DESCSANDING then drag the items to set the which column is sorted first -
Sort jTable rows by column as Integer value
Hi all,
I have problem with sort jTable rows. I have some columns and in first are integer data. jTable sort that as String value..1,10,11,12....2,21, ...
How can I do that?
ThanksIn the future, please post Swing questions to the Swing forum: http://forum.java.sun.com/forum.jspa?forumID=57
What does the TableModel's getColumnClass method return for that column? -
F2 key not working with custom JTable Column
I have a custom JTable Column (which is a JPanel with a JTextfield and JButton). Everything works as expected, except when the user presses "F2" to start editing the custom column cell. When the user presses F2, the custom cell goes into editing mode, but I am unable to type anything in it.
Below is the SSCCE.
Steps to Reproduce problem:
1) Run the Program
2) Select any cell in first Column.
3) Press "F2" and try to type into the cell. Can't type anything.
package com.ns;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.EventObject;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
public class TextButtonCellFrame extends javax.swing.JFrame {
// Variables declaration - do not modify
private JTextField inputText;
private JScrollPane jScrollPane1;
private JPanel testPanel;
private JTable testTable;
// End of variables declaration
public TextButtonCellFrame() {
initComponents();
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
testPanel = new JPanel();
jScrollPane1 = new JScrollPane();
testTable = new JTable();
inputText = new JTextField();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
testTable.setModel(new DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
testTable.setCellSelectionEnabled(true);
testTable.setRowHeight(52);
testTable.setSurrendersFocusOnKeystroke(true);
testTable.getColumnModel().getColumn(0).setCellRenderer(new MyTableCellRenderer());
testTable.getColumnModel().getColumn(0).setCellEditor(new MyTableCellEditor(new JTextField()));
testTable.getColumnModel().getColumn(0).setPreferredWidth(200);
jScrollPane1.setViewportView(testTable);
testPanel.add(jScrollPane1);
inputText.setPreferredSize(new Dimension(50, 20));
testPanel.add(inputText);
getContentPane().add(testPanel, BorderLayout.CENTER);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-576)/2, (screenSize.height-417)/2, 576, 417);
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TextButtonCellFrame().setVisible(true);
public class MyTableCellRenderer extends JPanel implements TableCellRenderer {
Point point;
JButton button1 = new JButton("Test 1");
JTextField txtField = new JTextField();
public MyTableCellRenderer() {
setLayout(new BorderLayout());
this.add(button1, BorderLayout.EAST);
this.add(txtField,BorderLayout.CENTER);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
if (isSelected) {
txtField.setBackground(testTable.getSelectionBackground());
txtField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
else {
txtField.setBackground(testTable.getBackground());
txtField.setBorder(null);
return this;
public class MyTableCellEditor extends DefaultCellEditor {
JPanel panel = new JPanel();
JButton button1 = new JButton ("Test 1");
JTextField txtField;
MyTableCellEditor(JTextField txtField) {
super (txtField);
this.txtField = txtField;
panel.setLayout(new BorderLayout());
panel.add(button1, BorderLayout.EAST);
panel.add(txtField,BorderLayout.CENTER);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == button1)
JOptionPane.showMessageDialog(null, "Action One Successful");
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
return panel;
public boolean isCellEditable(final EventObject anEvent) {
if (anEvent instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent) anEvent;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) {
txtField.setText(txtField.getText() + keyEvent.getKeyChar());
txtField.setCaretPosition(txtField.getText().length());
txtField.requestFocusInWindow();
return super.isCellEditable(anEvent);
}The code for isCellEditable(final EventObject anEvent) which is needed to edit the cell using keyboard was provided by DarrylBurke here
regards,
nirvan.The F2 key when pressed generates an action event (either JTable generates it or some other component). I am not sure how to handle the action event in the isCellEditable() method. Also, F(X) range of keys other than F2 dump some junk character in the JTextfield when pressed. I am now stuck at this point and don't know how handle F(X) range of keys.
regards,
nirvan. -
Move column from one place to another..
Hi
I need to arrange the order in which the columns are displayed in my ALV Grid displayed so that i can move the columns from one position to another but its not been allowed in the program so could u pls suggest which field needs to be set for this?
Regards
GunjanHi
You can use the following statement
ls_fcat-col_pos = 01.
By using this you can fix your column position
or else to sort the column try like this
sort-spos = '10'.
SORT-FIELDNAME = 'Years'.
SORT-TABNAME = 'DATA_TAB2'.
sort-UP = 'X'.
sort-subtot = 'X'.
SORT-GROUP = '* '.
APPEND SORT. CLEAR SORT.
In the It_SOET internal table write:
IT_SORT-Group = 'X'.
REPORT ZSDN .
TABLES : ekkn,ekko,EKPO,EKET,VBEP,LFA1.
TYPE-POOLS : slis, ICON.
DATA : DATE1 TYPE SY-DATUM.
data : begin of itab occurs 0,
VBELN like ekkn-VBELN, "SALE ORDER
VBELP LIKE EKKN-VBELP, "LINE ITEM
BEDAT LIKE EKKO-BEDAT, "DOCUMENT DATE
KUNNR LIKE VBAK-KUNNR, "SOLD TO PARTY
VBELN1 like VBEP-VBELN, "SALE ORDER1
POSNR1 LIKE VBEP-POSNR, "LINE ITEM
EDATU LIKE VBEP-EDATU, "END DATE
EMATN LIKE EKPO-EMATN, "STATUS
BMENG LIKE VBEP-BMENG, "DAYS
TDDAT LIKE VBEP-TDDAT, "START DATE
LMENG LIKE VBEP-LMENG, "DAYS -START DATE
LABNR LIKE EKPO-LABNR, "STATUS
PLNUM LIKE VBEP-PLNUM, "OVERALL STATUS
EKGRP like ekko-EKGRP, "PURCHASING GROUP
EBELN LIKE EKKN-EBELN, "PO NO
EBELP like ekkn-EBELP, "LINE ITEM
EINDT LIKE EKET-EINDT, "DELIVERY DATE
MATNR LIKE EKPO-MATNR, "MATERIAL NUMBER
TXZ01 LIKE EKPO-TXZ01, "MATERIAL TEXT
LIFNR LIKE EKKO-LIFNR, "VENDOR
MENGE LIKE EKPO-MENGE, "QUANTITY
WEMNG LIKE EKET-WEMNG, "GR QTY
WAMNG LIKE EKET-WAMNG, "BAL QTY
MEINS LIKE EKPO-MEINS, "OUn
NETPR LIKE EKPO-NETPR, "PRICE
LOEKZ LIKE EKPO-LOEKZ, "DELETED
LIFNR1 LIKE LFA1-LIFNR, "VENDOR
NAME1 LIKE LFA1-NAME1, "VENDOR NAME
WERKS LIKE EKPO-WERKS, "PLANT
end of itab.
DATA : BEGIN OF it_final OCCURS 0,
KUNNR LIKE VBAK-KUNNR, "SOLD TO PARTY
LABNR LIKE EKPO-LABNR, "STATUS
EMATN LIKE EKPO-EMATN, "STATUS
VBELN like ekkn-VBELN, "SALE ORDER
VBELP LIKE EKKN-VBELP, "LINE ITEM
BEDAT LIKE EKKO-BEDAT, "DOCUMENT DATE
EDATU LIKE VBEP-EDATU, "END DATE
TDDAT LIKE VBEP-TDDAT, "START DATE
PLNUM LIKE VBEP-PLNUM, "OVERALL STATUS
EKGRP like ekko-EKGRP, "PURCHASING GROUP
EBELN LIKE EKKN-EBELN, "PO NO
EBELP like ekkn-EBELP, "LINE ITEM
EINDT LIKE EKET-EINDT, "DELIVERY DATE
MATNR LIKE EKPO-MATNR, "MATERIAL NUMBER
TXZ01 LIKE EKPO-TXZ01, "MATERIAL TEXT
NAME1 LIKE LFA1-NAME1, "VENDOR NAME
MENGE LIKE EKPO-MENGE, "QUANTITY
WEMNG LIKE EKET-WEMNG, "GR QTY
WAMNG LIKE EKET-WAMNG, "BAL QTY
MEINS LIKE EKPO-MEINS, "OUn
NETPR LIKE EKPO-NETPR, "PRICE
WERKS LIKE EKPO-WERKS, "PLANT
END OF it_final.
DATA: color TYPE TABLE OF lvc_s_scol WITH HEADER LINE,
st_layout TYPE slis_layout_alv.
DATA : fcat TYPE slis_t_fieldcat_alv,
ls_fcat LIKE LINE OF fcat,
fheader TYPE TABLE OF slis_listheader WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0.
DATA :i_repid LIKE sy-repid,
gs_layout TYPE slis_layout_alv,
week type n.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: zso FOR ekkn-vbeln.
SELECT-OPTIONS: zpgr FOR ekko-EKGRP.
SELECT-OPTIONS: ZPL FOR EKPO-WERKS.
SELECTION-SCREEN END OF BLOCK bk1.
gs_layout-colwidth_optimize = 'X'.
select A~VBELN
A~VBELP
A~EBELN
A~EBELP
B~MATNR
B~TXZ01
B~MENGE
B~MEINS
B~NETPR
B~WERKS
B~LOEKZ
C~EINDT
C~WEMNG
D~EKGRP
D~LIFNR
D~BEDAT
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM EKKN AS A
INNER JOIN EKPO AS B ON A~EBELN = B~EBELN
AND A~EBELP = B~EBELP
INNER JOIN EKET AS C ON A~EBELN = C~EBELN
AND A~EBELP = C~EBELP
INNER JOIN EKKO AS D ON A~EBELN = D~EBELN
WHERE A~VBELN IN ZSO
AND D~EKGRP IN ZPGR
AND B~WERKS IN ZPL.
LOOP AT ITAB.
ITAB-WAMNG = ITAB-MENGE - ITAB-WEMNG.
SELECT SINGLE VBELN KUNNR
FROM VBAK INTO (ITAB-VBELN , ITAB-KUNNR )
WHERE VBELN = ITAB-VBELN.
SELECT SINGLE VBELN EDATU
FROM VBEP INTO (ITAB-VBELN , ITAB-EDATU)
WHERE VBELN = ITAB-VBELN.
DATE1 = SY-DATUM.
ITAB-BMENG = ITAB-EDATU - DATE1.
if itab-BMENG < 0.
ITAB-EMATN = 'OVER DUE'.
elseif itab-BMENG ge 0 AND itab-BMENG le 10.
ITAB-EMATN = 'CRITICAL'.
elseif itab-BMENG > 10.
ITAB-EMATN = 'UNDER FOLLOW-UP'.
endif.
SELECT SINGLE VBELN POSNR TDDAT
FROM VBEP INTO (ITAB-VBELN1 , ITAB-POSNR1 , ITAB-TDDAT)
WHERE VBELN = ITAB-VBELN AND
POSNR = ITAB-VBELP.
ITAB-LMENG = ITAB-TDDAT - DATE1.
if itab-LMENG < 0.
ITAB-LABNR = 'OVER DUE'.
elseif itab-LMENG ge 0 AND itab-LMENG le 10.
ITAB-LABNR = 'CRITICAL'.
elseif itab-LMENG > 10.
ITAB-LABNR = 'UNDER FOLLOW-UP'.
endif.
IF ITAB-WAMNG LE 0 OR
ITAB-LOEKZ = 'L' OR
ITAB-LOEKZ = 'S'.
ITAB-PLNUM = 'CLOSED'.
ELSE.
ITAB-PLNUM = 'OPEN'.
ENDIF.
SELECT SINGLE LIFNR NAME1
FROM LFA1 INTO (ITAB-LIFNR1 , ITAB-NAME1)
WHERE LIFNR = ITAB-LIFNR.
MODIFY ITAB.
ENDLOOP.
loop at itab.
move-corresponding itab to it_final.
append it_final.
endloop.
perform edit_mask.
i_repid = sy-repid.
PERFORM fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = fcat
i_save = 'A'
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form fieldcat
* text
* --> p1 text
* <-- p2 text
FORM fieldcat .
MOVE sy-repid TO i_repid.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-decimals_out = 2.
ls_fcat-col_pos = 1.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Sold to Party'.
ls_fcat-emphasize = 'C310'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 6.
ls_fcat-fieldname = 'LABNR'.
ls_fcat-outputlen = 20.
ls_fcat-seltext_m = 'Window Start Status'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C510'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 5.
ls_fcat-fieldname = 'EMATN'.
ls_fcat-outputlen = 15.
ls_fcat-seltext_m = 'Window End Status'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C410'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 2.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Sale Order'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C710'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 3.
ls_fcat-fieldname = 'VBELP'.
ls_fcat-outputlen = 5.
ls_fcat-seltext_m = 'Item'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C710'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 4.
ls_fcat-fieldname = 'EBELN'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'PO Number'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C710'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 7.
ls_fcat-fieldname = 'EBELP'.
ls_fcat-outputlen = 5.
ls_fcat-seltext_m = 'PO Item'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 8.
ls_fcat-fieldname = 'EKGRP'.
ls_fcat-outputlen = 3.
ls_fcat-seltext_m = 'Pur.Group'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 9.
ls_fcat-fieldname = 'BEDAT'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'PO Doc.Date'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 10.
ls_fcat-fieldname = 'EINDT'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'PO Delivery Date'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 11.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Material Number'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 12.
ls_fcat-fieldname = 'TXZ01'.
ls_fcat-outputlen = 15.
ls_fcat-seltext_m = 'Description'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 13.
ls_fcat-fieldname = 'NAME1'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Vendor'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C110'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 14.
ls_fcat-fieldname = 'MENGE'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'PO Quantity'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 15.
ls_fcat-fieldname = 'WEMNG'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Quantity Recvd'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 16.
ls_fcat-fieldname = 'WAMNG'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Bal Qty'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 17.
ls_fcat-fieldname = 'MEINS'.
ls_fcat-outputlen = 2.
ls_fcat-seltext_m = 'OUn'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 18.
ls_fcat-fieldname = 'NETPR'.
ls_fcat-outputlen = 8.
ls_fcat-seltext_m = 'NetPrice'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 19.
ls_fcat-fieldname = 'TDDAT'.
ls_fcat-outputlen = 15.
ls_fcat-seltext_m = 'Window Start date'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 20.
ls_fcat-fieldname = 'EDATU'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'Window End date'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 21.
ls_fcat-fieldname = 'PLNUM'.
ls_fcat-outputlen = 10.
ls_fcat-seltext_m = 'PO Status'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C610'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ls_fcat-col_pos = 22.
ls_fcat-fieldname = 'WERKS'.
ls_fcat-outputlen = 5.
ls_fcat-seltext_m = 'Plant'.
ls_fcat-tabname = 'IT_FINAL'.
ls_fcat-emphasize = 'C210'.
APPEND ls_fcat TO fcat.
clear ls_fcat.
ENDFORM. " fieldcat
*& Form edit_mask
* text
* --> p1 text
* <-- p2 text
FORM edit_mask .
loop at it_final.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = it_final-vbeln
IMPORTING
OUTPUT = it_final-vbeln.
Read table it_final.
* modify it_final.
endloop.
ENDFORM. " edit_mask
Reward all helpfull answers
Regards
Pavan -
Custom JTable column (JCheckBox) not included in row selection.
I am trying to use JCheckBox (for display only data) as one of my JTable columns. I have written custom cell renderer for the same. Every thing is working fine except that when I select a row, the new custom JCheckBox column is not included in selection. Here is the code that I am using.
protected class CheckBoxColumnRenderer extends DefaultTableCellRenderer {
JCheckBox ckb = new JCheckBox();
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Boolean) { // Boolean
ckb.setSelected(((Boolean) value));
ckb.setHorizontalAlignment(JLabel.CENTER);
ckb.setBackground(super.getBackground());
if (isSelected || hasFocus) {
ckb.setBackground(table.getSelectionBackground());
return ckb;
}How can I include the custom cell in the row selection.
regards,
nirvan.they have lots of dependencies and it is not always easy to strip out an SSCCE without a considerable effort.Exactly. And is the cause of the problem the dependencies or something else. The only way to know for sure is to strip out the code and simplify the problem, that way you truly understand what the problem is.
The majority of time this can be done with minimal effort as in this case.
Some times we are sure that the problem is with certain part of the code Is the problem the code or the way the code is invoked? How do we know the TableModel is created properly or that the column class is overwritten correctly when we can't see it?
someone having a third look at it may actually find the enhancement required with ease.Exactly, but we need to see the big picture.
So are you sure that I should post an SSCCE with every possible question where coding is involved ?In the majority of cases a SSCCE is easily created in 5-10 minutes, so if you want the fastest help then yes.
Just twice this past week I was ready to ask a question on the forum and was preparing a SSCCE to post and sure enough both times the creation of the SSCCE caused me to look at the problem differently and I solved it. I would much rather solve a problem on my own then post a question and wait for hours (days) hoping someone else knows the answer. -
ALV sort any column in fieldcatalog by default
hi all
i have developed report in ALV format. i have total 8 columns
normally we sort any column in the output only.
i have requirement that instead of sorting manually any column say Material no
it should be sorted by default when user execute the report. he should not do manually by pressing Sort button in
alv list
give code for refrencehi u can use the IT_SORT parameter of the FM REUSE_ALV_GRID_DISPLAY for this purpose.
specify the fields for which u need to sort ur table and the sorting order
( I have jst given da example for one field but this it_sort table can hav more than one fields.)
gs_alv_sort-spos = 1.
gs_alv_sort-fieldname = 'VKORG'. " Sales Org
gs_alv_sort-up = 'X'. " Ascending
APPEND gs_alv_sort TO gt_alv_sort.
then pass this internal table to teh alv fm
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = wf_repid
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
I_BACKGROUND_ID = 'WEAVE_BACKGROUND'
IS_LAYOUT = gs_alv_layout
IT_FIELDCAT = gt_alv_fieldcat
IT_SORT = gt_alv_sort
TABLES
T_OUTTAB = it_output
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2 -
In iTunes, is there any way to do a mass copy and paste of song titles from the "name" column to the "sort name" column? I know it can be done with individual titles but I have over 6,000 titles in my library.
Thank you. I have heard of Logic Pro 7, but I have never personally used it. I'm still growing in the world of Composition, and I know that it is something I will be studying in one of my Computer Music classes coming up for my degree. I think it is something I will look into getting once I can justify the price of it. I guess for the time being, I will continue to play and grow in my ability to use and take advantage of GB, and then see what I can do about or with Logic Pro when I'm ready. The thought of spending $1000 for a program is hard to bite, because I've already spent a lot to produce my music, not only electronic music, but also chamber music and so on. I had no idea it would be so expensive to dive deep into the world of composition! lol.
Finale 2007: $500
Sibelius 4: $500
Jam Packs: $400
Midi Keyboard Interface: $100
PowerBook: $1700
Printer for printing scores and analysis: $150
Logic Pro 7: Oy!
As you can see it adds up very quickly...that doesn't even include my personal instruments and study materials.
Thank you for your input, as I haven't really worked much with LP, and therefore didn't know which features are available. I will talk with some of my Composition buddies, and professors and see what they have to say as well, and who knows, I may be able to get the express version through one of them. -
How to catch selected text in JTable Column
Hi there,
I am learning JTable. Need help for How to get the selected text from the JTable Column which is set to be editable.
for example in JTextFiled you have method on getSelectedText(), is there any method for tracking the selected text.
Thanks in advance
MinalHere's an example of the model I used in my JTable. Not the "getValueAt" method & "getRecordAt" method. You will have to have a Record object - but it only contains the attributes of an inserted record (with appropriate getters & setters). Hope this helps.
public class FileModel5 extends AbstractTableModel
public boolean isEditable = false;
protected static int NUM_COLUMNS = 3;
// initialize number of rows to start out with ...
protected static int START_NUM_ROWS = 0;
protected int nextEmptyRow = 0;
protected int numRows = 0;
static final public String file = "File";
static final public String mailName = "Mail Id";
static final public String postName = "Post Office Id";
static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
// List of data
protected Vector data = null;
public FileModel5()
data = new Vector();
public boolean isCellEditable(int rowIndex, int columnIndex)
// The 2nd & 3rd column or Value field is editable
if(isEditable)
if(columnIndex > 0)
return true;
return false;
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c)
return getValueAt(0, c).getClass();
* Retrieves number of columns
public synchronized int getColumnCount()
return NUM_COLUMNS;
* Get a column name
public String getColumnName(int col)
return columnNames[col];
* Retrieves number of records
public synchronized int getRowCount()
if (numRows < START_NUM_ROWS)
return START_NUM_ROWS;
else
return numRows;
* Returns cell information of a record at location row,column
public synchronized Object getValueAt(int row, int column)
try
FileRecord5 p = (FileRecord5)data.elementAt(row);
switch (column)
case 0:
return (String)p.file;
case 1:
return (String)p.mailName;
case 2:
return (String)p.postName;
catch (Exception e)
return "";
public void setValueAt(Object aValue, int row, int column)
FileRecord5 arow = (FileRecord5)data.elementAt(row);
arow.setElementAt((String)aValue, column);
fireTableCellUpdated(row, column);
* Returns information of an entire record at location row
public synchronized FileRecord5 getRecordAt(int row) throws Exception
try
return (FileRecord5)data.elementAt(row);
catch (Exception e)
throw new Exception("Record not found");
* Used to add or update a record
* @param tableRecord
public synchronized void updateRecord(FileRecord5 tableRecord)
String file = tableRecord.file;
FileRecord5 p = null;
int index = -1;
boolean found = false;
boolean addedRow = false;
int i = 0;
while (!found && (i < nextEmptyRow))
p = (FileRecord5)data.elementAt(i);
if (p.file.equals(file))
found = true;
index = i;
} else
i++;
if (found)
{ //update
data.setElementAt(tableRecord, index);
else
if (numRows <= nextEmptyRow)
//add a row
numRows++;
addedRow = true;
index = nextEmptyRow;
data.addElement(tableRecord);
//Notify listeners that the data changed.
if (addedRow)
nextEmptyRow++;
fireTableRowsInserted(index, index);
else
fireTableRowsUpdated(index, index);
* Used to delete a record
public synchronized void deleteRecord(String file)
FileRecord5 p = null;
int index = -1;
boolean found = false;
int i = 0;
while (!found && (i < nextEmptyRow))
p = (FileRecord5)data.elementAt(i);
if (p.file.equals(file))
found = true;
index = i;
} else
i++;
if (found)
data.removeElementAt(i);
nextEmptyRow--;
numRows--;
fireTableRowsDeleted(START_NUM_ROWS, numRows);
* Clears all records
public synchronized void clear()
int oldNumRows = numRows;
numRows = START_NUM_ROWS;
data.removeAllElements();
nextEmptyRow = 0;
if (oldNumRows > START_NUM_ROWS)
fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
fireTableRowsUpdated(0, START_NUM_ROWS - 1);
* Loads the values into the combo box within the table for mail id
public void setUpMailColumn(JTable mapTable, ArrayList mailList)
TableColumn col = mapTable.getColumnModel().getColumn(1);
javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
int s = mailList.size();
for(int i=0; i<s; i++)
comboMail.addItem(mailList.get(i));
col.setCellEditor(new DefaultCellEditor(comboMail));
//Set up tool tips.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for mail Id list");
col.setCellRenderer(renderer);
//Set up tool tip for the mailName column header.
TableCellRenderer headerRenderer = col.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer)
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the Mail Id to see a list of choices");
* Loads the values into the combo box within the table for post office id
public void setUpPostColumn(JTable mapTable, ArrayList postList)
TableColumn col = mapTable.getColumnModel().getColumn(2);
javax.swing.JComboBox combo = new javax.swing.JComboBox();
int s = postList.size();
for(int i=0; i<s; i++)
combo.addItem(postList.get(i));
col.setCellEditor(new DefaultCellEditor(combo));
//Set up tool tips.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for post office Id list");
col.setCellRenderer(renderer);
//Set up tool tip for the mailName column header.
TableCellRenderer headerRenderer = col.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer)
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the Post Office Id to see a list of choices");
} -
Cannot sort a column in Numbers for iPad
I have a Numbers IOS spreadsheet on my iPad which contains 6 worsheets. I can sort the columns in all but one worksheet. In the problem worsheet, when I tap on the grey bar above any column, the menu that appears excludes the "Sort" option. What is wrong?
Generally, you are more likely to get an answer if you post in the iWork for iOS forum at
https://discussions.apple.com/community/app_store/iwork_for_ios
Cheers, Tom
Maybe you are looking for
-
How do I acquire images from my usb webcam ?
Hi all , How do I acquire images from my usb webcam (logitech quickcam express ) ? I use Labview 7 .
-
Update Oracle from 4.5 to 8i
How can I install Oracle 8i over older one (4.5) without affecting tables and information in the previous one. note: I am working on a network database and connecting to online ones. Please, help me. Regards, Hanady
-
RE: TOC grey boxes I can't get rid of.
On the TOC page in all the templates and also on the book I'm making there are two light grey box shapes showing at the bottom of the page that I can't get rid of. They don't respond to selecting, moving or deleting. My questions are: How do I get ri
-
Logging software - shrinking file size and keeping timecode
I recently found and downloaded the trial version of InqScribe Transcription Software (http://www.inqscribe.com/index.html). It seems pretty neat. You can open up and video file in the program and it read the timecode from the file and inserts it int
-
MBAM client installation fails
I facing a strange issue while installing MBAM client in windows 7 enterprise. I am using the CLI method to install client on Test machines and it give error "Program to big to fit into Memory". Did anyone faced this kind of issue? If yes please advi