nattable multiple row selection - java

I am using NatTable and I want to select some rows in my table. Additional I want to select some other rows after this (CTRL + left mouse-click).
There is no problem with the first selection, but when I try to select some additional rows, my first selection got lost. This happens only if I do my second selection in dragmode. When I select every additional row by single clicking everything works fine.
I used the RowSelectionModel with the DefaultRowSelectionLayerConfiguration:
selectionLayer.setSelectionModel(new RowSelectionModel<Entry>(selectionLayer, bodyDataProvider, new IRowIdAccessor<Entry>() {
#Override
public Serializable getRowId(Entry rowObject) {
return rowObject.getStartLine();
}
}));
selectionLayer.addConfiguration(new DefaultRowSelectionLayerConfiguration());
Maybe I just did a silly mistake and you guys can help me.

It looks like an issue in the NatTable code. I created a ticket for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=494392

Related

How to remove item in JTable also remove from Database?

I am pretty basic to link from Java to Database.
I link item from Database (I use MS.Access) to Java table (JTable)
but when I delete in JTable using this code
int numRows = tblweng.getSelectedRows().length;
for(int i=0; i<numRows ; i++ )
((DefaultTableModel)tblweng.getModel()).removeRow(tblweng.getSelectedRow());
it deletes only in Table but not in Database. So how I can remove both of them at the same time I click "Remove Button".
Please guide me but don't go too deep I am just a basic here. Thank in advance.
1. click Jtable // row selected
2. get data form dep_Table like
int a = dep_Table.getSelectedRow();
String b = String.valueOf(dep_Table.getValueAt(a, 1));
3. What data you want in you get and store in String
4. Connect Database
5. use Delete Query and Delete Data From Database
6. Reload Table Again
These Few basic Step is Enough for You.. I Think..

JTable, disable user column dragging

I have declared my JTable as:
data_table = new JTable(info, header) {
#Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
But I've seen that at runtime it's possible to drag the columns with mouse.
How can I disable that?
data_table.getTableHeader().setReorderingAllowed(false); should do the job, unless you mean that the user can resize column headers.
To anyone having this problem using Netbeans IDE you can disable the user from dragging columns in the JTable by doing the following steps.
Right click the table
Select Table contents
Click the columns tab
Uncheck the Allow to reorder columns by drag and drop

Cannot delete all rows from my SQLite DB

I am populating an alertDialog from my database allowing a user to select a preset email message template. The populating seems to work but I cannot delete or edit it, only add to it. I wanted to delete all the rows and basically repopulate it from the beginning but I can seem to delete a single entry or all entries.
This is my deleting method in my DB Handler class:
public void deleteAppointment() {
ourDatabase.delete(DATABASE_TABLETEMP, null, null);
}
This code I have used to try and delete all the rows but it dosent. Can anyone see where I am going wrong?
You can do:
Drop table tablename
--run rebuild scripts

SmartGWT ListGrid - exclude field from selection

I would like to ask for your help to solve the following problem.
I have a SmartGwt ListGrid wich has multiple rows in it.
This ListGrid has a SelectionChangedHandler which works just fine.
I added a special column (ListGridField) to this ListGrid, on which basically I want to prevent the selectionChangeEvent to trigger when clicked.
This special column has its own recordclickHandler.
I only want to EXCLUDE this column form changing the selected record in the ListGrid.
Is there any way to do so in your knowledge?
Thanks in advance.
Since the event for row selection doesn't tell you which cell you clicked on, hence no way of telling which column, I think you'll need to make cells selectable, and ignore the event if the cell is in the excluded column.
myGrid.setCanSelectCells(true);
myGrid.addCellSelectionChangedHandler(new CellSelectionChangedHandler() {
public void onCellSelectionChanged(CellSelectionChangedEvent event) {
CellSelection selection = countryGrid.getCellSelection();
//use to determine if excluded column is clicked:
int[][] selectedCells = selection.getSelectedCells();
//use to get selected row:
ListGridRecord record = selection.getSelectedRecord();
//etc...
}
}

Android db.update not work if use db.delete first

I have a strange problem to update a table in my database...forgive me if I can not explain well but I'm a bit confused...
The problem is this:
I created a table with values, I read this values in my listview..everything works for now..insert and delete values works without problem..now created a loop in a service why do I need to make a comparison between a value and a string of my database and when this comparison is true, I need to change a value in my table..
The real problem is this: my db.update works only if not use ... never, the command db.delete... if use it, the db.update not work anymore ..and to make it work again, i need to make a new AVD.
how is it possible?
my db.delete and id is this:
item.getMenuInfo();
id = getListAdapter().getItemId(info.position);
public void deleteReg(SQLiteDatabase db ,long id)
{
db.delete(TabRegistry.TABLE_NAME, TabRegistry._ID + "=" + id, null);
}
on activity:
databaseHelper.deleteReg(db, id);
my db.update is this: (positions is a value of getPositions(),for locate a positions with a cursor(always works, even when fails db.update))
public void updateReg(SQLiteDatabase db,int positions, String stat)
{
ContentValues v = new ContentValues();
v.put(TabRegistry.STATUS, stat);
db.update(TabRegistry.TABLE_NAME, v, TabRegistry._ID + " = " + positions, null);
}
on service:
databaseHelper.updateReg(db, positions, "SUCCESS");
if you need more code, tell me what I add now..thanks in advance
The SQLite api you are using is based off of CRUD operations (you should read this).
You are DELETE-ing the record from the database, therefore there is nothing to UPDATE when you attempt to update it. If you want to create a new record, or recreate the one you deleted then you would perform an INSERT instead of an UPDATE.
EDIT:
It also appears you are passing in position number to the update and delete. I assume that you are also using this value to place the record in your table? Is it possible that when you delete the record from the table and the database, that the other records now have an invalid position because they haven't been updated also? It's just a shot in the dark, figured I might as well ask.

Categories