Table Sorting based on Column Selection
Dear All,
I am using an AbstractTableModel. I would like to implement the sorting based on Column selection. Could anyone help me in this please.
Thanks in advance,
Regards
Irfaan
check this
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Hashtable;
public class TableSorter extends JPanel
private boolean DEBUG = false;
private Object[] columnNames = { "First Name", "Last Name", "Sport", "# of Years",
"Vegetarian"};
private Object[][] data = { { "Mary", "Campione", "Snowboarding", 1, 2 },
{ "Alison", "Huml", "Rowing", 3, 4 }, { "Kathy", "Walrath", "Knitting", 5, 9 },
{ "Sharon", "Zakhour", "Speed reading", 6, 10 }, { "Philip", "Milne", "Pool", 7, 11 },
{ "Isaac", "Rabinovitch", "Nitpicking", 8, 12 }, };
private SortFilterModel m_modSortFilterModel;
private TableColumnModel m_modColumnModel;
private TableHeaderRenderer m_btnSorterRenderer;
protected boolean m_bAbCOC = true;
JTable table = new JTable();
public TableSorter()
super(new GridLayout(1, 0));
m_modSortFilterModel = new SortFilterModel();
m_modSortFilterModel.addMouseListener(table);
table.setModel(m_modSortFilterModel);
m_btnSorterRenderer = new TableHeaderRenderer();
m_modColumnModel = table.getColumnModel();
for (int i = 0; i < columnNames.length; i++)
m_modColumnModel.getColumn(i).setHeaderRenderer(m_btnSorterRenderer);
JScrollPane scrollPane = new JScrollPane(table);
add(scrollPane);
private class SortFilterModel extends AbstractTableModel
int[] indexes;
ATSTableSorter sorter;
public String[] tableHeadersArray;
boolean isAscent = true;
public void addMouseListener(final JTable table)
table.getTableHeader().addMouseListener(new MouseAdapter()
public void mouseClicked(MouseEvent event)
int tableColumn = table.columnAtPoint(event.getPoint());
m_btnSorterRenderer.setPressedColumn(tableColumn);
m_btnSorterRenderer.setSelectedColumn(tableColumn);
if (TableHeaderRenderer.DOWN == m_btnSorterRenderer.getState(tableColumn))
isAscent = true;
else
isAscent = false;
// translate to table model index and sort
int modelColumn = table.convertColumnIndexToModel(tableColumn);
sortByColumn(modelColumn, isAscent);
public Object getValueAt(int row, int col)
int rowIndex = row;
if (indexes != null)
rowIndex = indexes[row];
return data[rowIndex][col];
public void setValueAt(Object value, int row, int col)
int rowIndex = row;
if (indexes != null)
rowIndex = indexes[row];
super.setValueAt(value, rowIndex, col);
public void sortByColumn(int column, boolean isAscent)
if (sorter == null)
sorter = new ATSTableSorter(this);
sorter.sort(column, isAscent);
fireTableDataChanged();
public int[] getIndexes()
int n = getRowCount();
if (indexes != null)
if (indexes.length == n)
return indexes;
indexes = new int[n];
for (int i = 0; i < n; i++)
indexes[i] = i;
return indexes;
public int getRowCount()
return data.length;
public String getColumnName(int c)
return columnNames[c].toString();
public int getColumnCount()
return columnNames.length;
public Class getColumnClass(int col)
switch (col)
case 0:
return String.class;
case 1:
return String.class;
case 2:
return String.class;
case 3:
return Integer.class;
case 4:
return Integer.class;
default:
return Object.class;
class ATSTableSorter
SortFilterModel model;
public ATSTableSorter(SortFilterModel model)
this.model = model;
public void sort(int column, boolean isAscent)
int n = model.getRowCount();
int[] indexes = model.getIndexes();
for (int i = 0; i < n - 1; i++)
int k = i;
for (int j = i + 1; j < n; j++)
if (isAscent)
if (compare(column, j, k) < 0)
k = j;
else
if (compare(column, j, k) > 0)
k = j;
int tmp = indexes;
indexes[i] = indexes[k];
indexes[k] = tmp;
public int compare(int column, int row1, int row2)
Object o1 = model.getValueAt(row1, column);
Object o2 = model.getValueAt(row2, column);
if (o1 == null && o2 == null)
return 0;
else if (o1 == null)
return -1;
else if (o2 == null)
return 1;
else
Class type = model.getColumnClass(column);
if (type.getSuperclass() == Number.class)
return compare((Number) o1, (Number) o2);
else if (type == String.class)
return ((String) o1).compareTo((String) o2);
else
return ((String) o1).compareTo((String) o2);
public int compare(Number o1, Number o2)
double n1 = o1.doubleValue();
double n2 = o2.doubleValue();
if (n1 < n2)
return -1;
else if (n1 > n2)
return 1;
else
return 0;
class TableHeaderRenderer extends JButton implements TableCellRenderer
public static final int NONE = 0;
public static final int DOWN = 1;
public static final int UP = 2;
int pushedColumn;
Hashtable state;
public TableHeaderRenderer()
pushedColumn = -1;
state = new Hashtable();
setMargin(new Insets(0, 0, 0, 0));
setHorizontalTextPosition(LEFT);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column)
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
boolean isPressed = (column == pushedColumn);
getModel().setPressed(isPressed);
getModel().setArmed(isPressed);
return this;
public void setPressedColumn(int col)
pushedColumn = col;
public void setSelectedColumn(int col)
if (col < 0)
return;
Integer value = null;
Object obj = state.get(new Integer(col));
if (obj == null)
value = new Integer(DOWN);
else
if (((Integer) obj).intValue() == DOWN)
value = new Integer(UP);
else
value = new Integer(DOWN);
state.clear();
state.put(new Integer(col), value);
public int getState(int col)
int retValue;
Object obj = state.get(new Integer(col));
if (obj == null)
retValue = NONE;
else
if (((Integer) obj).intValue() == DOWN)
retValue = DOWN;
else
retValue = UP;
return retValue;
private static void createAndShowGUI()
JFrame frame = new JFrame("TableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TableSorter newContentPane = new TableSorter();
newContentPane.setOpaque(true); // content panes must be opaque
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
public static void main(String[] args)
javax.swing.SwingUtilities.invokeLater(new Runnable()
public void run()
createAndShowGUI();
Similar Messages
-
Update columns in Table A based on columns in Table B for more than 500K rows
Guys,
I need to update 9 columns in table A based on value from table B for for more than 500K rows.
So what is best way to achieve this. I am thinking of writing a Procedure with cursor to update the rows of table A.
When i googled about it, they say cursor will decrease the performance. So i have no clue how to go for this.
Rough code which i though
1) Procedure with no parameter
2) Will declare 9 variable to store value from cursor
3) cursor will fetch row by row based on join condition between table a and table b
4) i will pass column values from table B to variables
5) will make an update statement for table A
Please let me know if above method is correct or is there any other way to do this without using cursor.Guys,
Below is the rough code i wrote as per my requirement. Does it look correct? As of now i dont have any platform to test it so any help with the below code is highly appreciated. As i said i need to update more than 500K rows by matching Table
A and Table B. One more thing which i would like to add in below code, is to get log of all the rows that are in table B but not exist in table A. Table A already has more than million data in it.
Also not sure how the loop in below code willl run when @rowcount is become to zero?
Please let me know if i need to consider performance related impact while running the script.
GO
SET SERVEROUTPUT ON
CREATE PROCEDURE ONETIMEUPDATE
DECLARE @cnt INT;
SET @cnt = 1;
DECLARE @MSG varchar(255);
DECLARE @COUNT_VAR INT;
SET @COUNT_VAR=0;
WHILE @cnt > 0
BEGIN
Update TOP (50000) A
Set A.Col1=B.Col1,
A.COL2=B.COL2,
A.COL3=B.COL3,
A.COL4=B.COL4,
A.COL5=B.COL5,
A.COL6=B.COL6,
A.COL7=B.COL7
From TableA A
Inner Join TableB B
on A.ID = B.ID--ID
WHERE A.Col1 <> B.Col1
OR A.Col2 <> B.Col2;
SET @cnt = @@ROWCOUNT;
IF @@ROWCOUNT=25000
@COUNT_VAR=@COUNT_VAR + @@ROWCOUNT
SELECT @MSG = CONVERT(varchar, @COUNT_VAR) + "Rows Updated" -- I WANT TO DISPLAY UPDATE after EVERY 25000 ROWS
PRINT @MSG
IF @@ROWCOUNT=0
BEGIN
COMMIT
END
WAITFOR DELAY '00:00:01' --wait for a second before the next update
END;
END; -
Calling table maintainance based on particular selection criteria
Hi All,
I have created a transaction code for a table. I want to call this table using the transaction from a module pool. I also created the table maintainance genereator for the table.
Here the requirement is I want to display the table details based on the plant. (My table contains plant as one of the field.and entries will be maintained for each plant).
My module pool screen contains few pushbuttons. If I press one of the push button it should take me to the maintainance screen of the table for that particular plant.
Regards,
Kishore.Hi,
Use the FM VIEW_MAINTENANCE_CALL as shown below.
action = 'U'.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = action "'U'
* CORR_NUMBER = ' '
* GENERATE_MAINT_TOOL_IF_MISSING = ' '
* SHOW_SELECTION_POPUP = ' '
view_name = <UR Z TABLE NAME>
* NO_WARNING_FOR_CLIENTINDEP = ' '
* RFC_DESTINATION_FOR_UPGRADE = ' '
* CLIENT_FOR_UPGRADE = ' '
* VARIANT_FOR_SELECTION = ' '
EXCEPTIONS
client_reference = 1
foreign_lock = 2
invalid_action = 3
no_clientindependent_auth = 4
no_database_function = 5
no_editor_function = 6
no_show_auth = 7
no_tvdir_entry = 8
no_upd_auth = 9
only_show_allowed = 10
system_failure = 11
unknown_field_in_dba_sellist = 12
view_not_found = 13
OTHERS = 14.
Thanks
Nayan -
SP2013 Is it possible to show/hide columns based on column selections?
SharePoint 2013
I have a lists with a school district selection choice column (refer to as column A). Then I have three other columns with schools based on district. What I would like to do is only show schools in a certain district based on what district
is selected in column A. Can anyone tell me if this is possible and if so, how can i acheive it?It generally takes a little script to get the cascading right;
http://sharepoint-works.blogspot.ch/2012/02/cascading-dropdown-or-filtered-values.html
https://www.youtube.com/watch?v=70-hXWY6ARY
InfoPath is another possibility. Are you using that?
w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | YouTube: http://www.youtube.com/user/JamieMcAllisterMVP -
Report generation based on columns selected by user
Hi All,
I have gone through many posts with key column selector, fact selection not able to find solution to my issue, hence putting this infront of you.
In OBI Dashboard, I have dashboard prompts for dimensions with multiselect, based on the values selected report is generated.
Now user has a requirement in which, they should be able to select only those facts they are interested in; they want all column names to be listed in a multiselect prompt, only the selected facts should be present in the result(Report has around 20 fact columns)
Also there are 6 dimensions which are dashboard prompts (filters) they should be always displayed in the result and not to be listed in fact list that will be given to user for selection.
Obiee version : 10.1.3.4
Can any one please give me ideas to achieve this?
Thanks in advance,
SrlSo,
1. Have 6 Dim columns and set as prompted in the report and use prompts the standard way in a report as we know
2. Now use column selector in the Report where you place all the desired fact columns inside 4 anchored columns.
Ex. If you decide 4 column selector anchors and these 4 having all 20 fact columns in each, facilitates the user to run a report selecting any 4 metrics at one time, with the prompted selections
- dependency is user must run all 4 fact columns, could be 4 different fact columns or same fact column 4 times within the same report
- you may increase from 4 to 6 or so but user must select from all column selectors
Key is 'place all the desired fact columns inside 4 anchored columns'
Try this and see if this meets yours -
Multiple column selection in ssrs report
Hi all
I am developing one report
which would be based on column selection combo
what i want to achieve...
i will use Store procedure
and in my report i want multi select parameter called @Column_To_Select
i want available values for combobox as total column names which is return by store procedure
and when i select column1 is should only display column1 from tablix
can one help how can i get column names from store procedure
Dilip Patil..You cant alter dataset like this. metadata has to be constant for SSRS report to work properly.
I think your requirement should be implemented as follows. Always bring all columns from query inside dataset. Then in your report container (tablix/matrix) set an expression for columns visibility property to show only when select parameter value has the
column name.
The expression would be like below for hidden property each column
=IIF(InStr("," & Join(Parameters!Columnnames.Value,",") & ",",",ColumnName,")>0,False,True)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Extract XML data based on column tag
Dear All,
i want to extract the XML data type based on column selection.
For example:
i have the below xml in my database stored as XMLTYPE() data.
<c1>10</c1><c2>0011</c2><c3>DEBIT</c3><c4>USD</c4>
i want to extract the column tag c2&c3 alone. Is there any query to extract the same.
Waiting for your response.Thanks in Advance.Hi,
How do I set the web service option up correctly? The XMLs are being created behind the scenes on what data to be used but I don't know how to make the menu only pick the xml based on the menu option.
I have one XML that populates the menu options and specific XML's that has the data that goes with each menu option. The menu population works great but it doesn't pull the other XML's to populate the charts. This is the part that I need help.
How do I use the web service to fix this? Any help would be very much appriecated. I could even send you my dashboard if it helps so you can see what I've gotten so far (it's not all prettied up yet since I wanted to see if it's doable first)
I'm new to Xcelsius so I apologize if these are newbie questions.
Thanks,
Jay -
Sorting based on non-base table columns
I have a form block based on X table. There are also some columns from Y table in the same block and the tables X and Y are joined through the appropriate columns. I want to sort the queried record in the block ( based on table X ) based on two columns that are present in the Y table. How do I do this? Any help would be highly appreciated. Ofcourse! we can create a view and achieve that. But I don't want to create a view. Also I can use select statement in the order by column. But it works if I select one column. But when I select two columns it says too many value. Any solutions
why dont u create a function
and sort by the returning values ? -
ADF Table sorting on Select One choice column display value
Hi Team,
We are using an ADF with EJB application.
I have an ADF table, which has a select one choice in it. (The Select one Choice list elements are populated from a java bean).
Presetnly, when we perform the sorting on this SOC column, the table is getting sorted based on SOC value not on the Label.
How to sort this column based on the SOC Lable filed.
Please help us.
Thank you,
Keshav ChHi Frank,
I took a transient column in the Entity and populated this column with the LOV label value.
In the ADF added this coulmn to the table and set it is rendered false.
Set the sortable property of the lov column to the new trasient column.
Now the sort will work with the label filed (Transient Column)
Thank you,
Keshav ch -
Hi All,
Suppose I have table, whose structure changes frequently on daily basis.
For eg. desc my_table gives you following column name on Day 1
SQL > desc my_table;
Output
Name
Age
Phone
On Day 2, two more columns are added, viz, Address and Salary.
SQL > desc my_table;
Output
Name
Age
Phone
Address
Salary
Now I want to create an Dynnamic RTF report which would fetch data from ALL columns from my_table on daily basis. For that I have defined a concurrent program with XML as output type and have attached a data template/data definition to it which takes in XML as input and gives final output of conc program in EXCEL layout. I am able to do this for constant number of columns, but dont know how to do it when the number of columns to be displayed changes dynamically.
For Day 1 my XML file should be like this.
<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
SELECT Name
,Age
,Phone
FROM my_table
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_my_table" source="Q2">
<element name="Name" value="Name" />
<element name="Age" value="Age" />
<element name="Phone" value="Phone" />
</group>
</dataStructure>
</dataTemplate>
And my Day 1, EXCEL output from RTF template should be like this.
Name Age Phone
Swapnill 23 12345
For Day 2 my XML file should be like this. With 2 new columns selected in SELECT clause.
<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="XYZ" description="iExpenses Report" Version="1.0">
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
SELECT Name
,Age
,Phone
,Address
,Salary
FROM my_table
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_my_table" source="Q2">
<element name="Name" value="Name" />
<element name="Age" value="Age" />
<element name="Phone" value="Phone" />
<element name="Address" value="Address" />
<element name="Salary" value="Salary" />
</group>
</dataStructure>
</dataTemplate>
And my Day 2, EXCEL output from RTF template should be like this.
Name Age Phone Address Salary
Swapnill 23 12345 Madrid 100000
Now, I dont know below things.
Make the XML dynamic as in on Day 1 there must be 3 columns in the SELECT statement and on Day 2, 5 columns. I want to create one dynamic XML which should not be required to be changed if new columns are added in my_table. I dont know how to create this query and also create their corresponding elements below.
Make the RTF template dyanamic as in Day1 there must 3 columns in EXCEL output and on Day 2, 5 columns. I want to create a Dynamic RTF template which would show all the columns selected in Dynamic XML.I dont know how the RTF will create new XML tags and how it will know where to place it in the report. Means, I can create RTF template on Day 1, by loading XML data for 3 columns and placing 3 XML tags in template. But how will it create and place tags for new columns on Day 2?
Hope, you got my requirement, its a challenging one. Please let me know how I can implement the required solution using RTF dynamically without any manual intervention.
Regards,
Swapnil K.
Message was edited by: SwapnilKHi All,
I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
Please let me know if there is any oracle functionality to do this.
If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
For eg, /$APPL_TOP/ar/1.0/sql or something.
Regards,
Swapnil K. -
Pivot table sorting with month_id and average column in BI publisher temp
In my project we are using the Oracle BI analysis for creating reports in BI publisher.
At first we are creating the report in OBIEE answers then using it as data model in BI Pub.
My reporting table holds data like below:
Month_Name Year Month_Id Compensation Emp ID
JAN 2011 1000 50 1234
FEB 2011 1001 60 1235
We need to show the data in pivot format i.e period(concated month+year) in column and comepsation values as measure and emp id in rows.I also need to show percentage i.e sum(Compensation/no of selected of periods).
For average in OBIEE pivot i have create one calulated item. But I can't sort the data(for periods with the month_id) as its spillting the average column also.
How can i sort it? like JAN2011 FEB2011 MAR2011 in pivot
also in BI pub this calculated item not showing correct value.
Please help.Hi,
You can achieve this requirement by sort order column based on the month number and year you can sort this criteria column.also by using time_key,if the time_key is in sequence.
mark if helpful/correct...
thanks,
prassu -
Sorting based on a specific value in Columns
Hi All,
Crystal 2008 version I have. And we are connecting to BW queries as source.
In a crosstab, I want to sort my row values based on a column value.
For example, in rows I have an element with three values . In column I have only one element(month), with couple of month values. My requirement is to sort rows based on a specific month (Mar'09 for example).
.....................Jan'09......Feb'09.....Mar'09
ABC...............10.............323...........33....
XYZ...............32..............33............11....
FGH...............5................34.............55...
But when I try to sort based on the Month, I can not select a specific value(mar'09). And it sorts based on the total value (sum of all months).
How can I achieve this problem?
Thanks
OzanFor {Sort Value}, if you wanted to sort on the Jan column, then substitute the field name that your example shows as 10 in row ABC. For {row value}, substitute the field name that is used in the first column (ABC in the example).
In other words, take the value that you want to sort on, and put it in front of the value currently displaying as the row header. Then, sort on the results.
The purpose of the "000000000.00" is to make the length of the number, when converted to string, a consistent size. This is needed (a) so you know how many characters to strip off when displaying the row value, and (b) so the records don't sort as 1, 12, 2, 234, 235423, 25, 3, ...
HTH,
Carl -
Dynamically enable a field based on a selected table row
Hi everyone.
I'm getting really confused right now, please show me the right way. My approach may be, and probably is, wrong since I am self learning this and all I have is an ASP.NET background.
I have a page with a table in it. I've created a DataControl for a collection I've made and mapped it to the table. I added a column that shows an "edit" button. On it's click, I open a popup that shows the selected row's data. Naviguation controls are also present on the popup.
This is working fine.
My problem comes in the popup. Each row has multiples fields. These fields, shown on the popup, need to dynamically be enable/disable. To toggle those field, the only way I can see right now is to have a function that takes into parameter the rowId and the fieldName. Based on those two fields, I can get the necessary information to know if I need to enable or disable the control.
What I was aiming for, but then again I totally failed, was to have that function called on the "enabled" EL Expression, returning a Boolean.
Now that this has been said, can someone guide my on how to dynamically enable/disable each field based on the selected row.
Thanks !Above +
why don't you create a bean method that returns a Boolean ans through EL Expression Builder select the method to this property.
btw .. on which components are you setting this?
Also,
If there is business logic that prohibits to update this object unless that is met.. you can also do it as..
In EOImpl .. override isAttributeUpdateable(int i) method eg:
@Override
public boolean isAttributeUpdateable(int i) {
if(i == this.ENAME && "KING".equalsIgnoreCase(this.getEname())){
return true;
}else
return super.isAttributeUpdateable(i);
and then in UI for the component say
ReadOnly = #{bindings.Ename.updateable}
Or, In UI
disable = #{ bindings.Ename.attributeValue == 'KING' & bindings.Mrg.attributeValue == null ? true : false}
adf does provides many ways to do it ..
Cheers, Amit -
Custom table model, table sorter, and cell renderer to use hidden columns
Hello,
I'm having a hard time figuring out the best way to go about this. I currently have a JTable with an custom table model to make the cells immutable. Furthermore, I have a "hidden" column in the table model so that I can access the items selected from a database by their recid, and then another hidden column that keeps track of the appropriate color for a custom cell renderer.
Subject -- Sender -- Date hidden rec id color
Hello Pete Jan 15, 2003 2900 blue
Basically, when a row is selected, it grabs the record id from the hidden column. This essentially allows me to have a data[][] object independent of the one that is used to display the JTable. Instinctively, this does not seem right, but I don't know how else to do it. I know that the DefaultTableModel uses a Vector even when it's constructed with an array and I've read elsewhere that it's not a good idea to do what I'm trying to do.
The other complication is that I have a table sorter as well. So, when it sorts the objects in the table, I have it recreate the data array and then set the data array of the ImmutableTableModel when it has rearranged all of the items in the array.
On top of this, I have a custom cell renderer as well. This checks yet another hidden field and displays the row accordingly. So, not only does the table sort need to inform the table model of a change in the data structure, but also the cell renderer.
Is there a better way to keep the data in sync between all of these?To the OP, having hidden columns is just fine, I do that all the time.. Nothing says you have to display ALL the info you have..
Now, the column appears to be sorting properly
whenever a new row is added. However, when I attempt
to remove the selected row, it now removes a seemingly
random row and I am left with an unselectable blank
line in my JTable.I have a class that uses an int[] to index the data.. The table model displays rows in order of the index, not the actual order of the data (in my case a Vector of Object[]'s).. Saves a lotta work when sorting..
If you're using a similar indexing scheme: If you're deleting a row, you have to delete the data in the vector at the INDEX table.getSelectedRow(), not the actual data contained at
vector.elementAt(table.getSelectedRow()). This would account for a seemingly 'random' row getting deleted, instead of the row you intend.
Because the row is unselectable, it sounds like you have a null in your model where you should have a row of data.. When you do
vector.removeElementAt(int), the Vector class packs itself. An array does not. If you have an array, when you delete the row you must make sure you dont have that gap.. Make a new array of
(old array length-1), populate it, and give it back to your model.. Using Vectors makes this automatic.
Also, you must make sure your model knows the data changed:
model.fireTableDataChanged(); otherwise it has no idea anything happened..
IDK if that's how you're doing it, but it sounds remarkably similar to what I went thru when I put all this together.. -
URGENT - Does Select Query Sort based on RowId ?
Does Select Query Sort based on RowId ?
Eg: Select * from Employee;
RowId primkey name
aaaa 1 kiran
aaab 2 kumar
aaac 3 someone
Now when i delete the primkey: 2 row.
I will have:
RowId primkey name
aaaa 1 kiran
aaac 3 someone
Now when i insert a new record:
RowId primkey name
aaaa 1 kiran
aaac 3 someone
[Comment: Here the rowid can either be a new one like 'aaad' or 'aaab' is also reused.]
aaad 4 somename
My requirement is that the 'aaab' should not be reused.
Can any one pls suggest some way.Dear Friend,
Plese gothrougth once following steps... (One by One)
Hope you can understand how Rowid Creating and Updting in you table.
SQL> select rowid,enumber from t;
ROWID ENUMBER
AAAJ4oAABAAAWlyAAA 1
AAAJ4oAABAAAWlyAAB 2
AAAJ4oAABAAAWlyAAC 3
AAAJ4oAABAAAWlyAAD 4
SQL> select rowid,enumber from t where enumber = 2;
1 row deleted.
SQL> insert into t values(9):
1 row created.
SQL> select rowid,enumber from t;
ROWID ENUMBER
AAAJ4oAABAAAWlyAAA 1
AAAJ4oAABAAAWlyAAC 3
AAAJ4oAABAAAWlyAAD 4
AAAJ4oAABAAAWlyAAE 9
SQL> delete from t where enumber = 3;
1 row deleted.
SQL> insert into t values(3);
1 row created.
SQL> select rowid,enumber from t;
ROWID ENUMBER
AAAJ4oAABAAAWlyAAA 1
AAAJ4oAABAAAWlyAAB 3
AAAJ4oAABAAAWlyAAD 4
AAAJ4oAABAAAWlyAAE 9
Regards,
G V Sreenivasulu
Maybe you are looking for
-
I got butter in my iphone 5 top speaker near the from camera
do you think I should get it checked out by apple to make sure nothing is wrong and see if they can clean it! I was testing it and it sounded quiet and then I cleaned it and now it sounds normal but I am not sure.
-
I have a two-finger scrolling problem with my 5- day- old Macbook (10.5, Firefox latest version). It was suggested in this forum that I turn off Horizontal scrolling. I did that, in fact I think I tried every combination of settings on the Keyboard &
-
"AdobeFnt13.lst" file missing in the document fonts folder
Hello, I have a bug with Indesign CS5, the "AdobeFnt13.lst" file is now missing in my document fonts folders, even after reinstall of ID. I deleted the Preferences folder, font cache etc. nothing works so far. An idea someone ?
-
Decreasing the font size in a Classical report
Hi all, i have to decrease the font size in the output of a classical report while printing. I have tried the following snippet: NEW-PAGE PRINT ON LINE-SIZE zeichen_pro_zeile LINE-COUNT zeilen_pro_seite NEW LIS
-
Artist name for compilation albums (No album for artist alone present)
When I have a compilation album, fe Route 66 (including a song from Steppenwolf) and a Steppenwolf album (Steppenwolf : 16 greatest hits), i can see Steppenwolf in the 'artist view', and see the 2 albums. When an artist only appears on a compilation