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...
}
}
Related
I'm creating a zk component for mount easy grid from view database. One of its powerful features is the automatic generation of filters by column. These filters appear automatically on the top column inside the auxheader tag and all are generated programmatically in java with the column info. Example of database view TIMESTAMP column (sorry not css right now):
https://prnt.sc/ZK9nMws2l68p
My problem now is that I don't know how to bind these datebox generated programmatically in java with the view for recovering the filter values.
I was searching inside the zkoss wiki and only found this:
create data binding programmatically,
where you can find how bind zk components of the zul, or how bind components generated programatically if the parent has an item render option.
But i need generate N datebox, numberbox, textbox depending on the number and type of the columns and recover the values of it.
Anyone knows how do it?
The component has a loot of code and scrap, but more or less the idea is:
https://pastebin.com/Q5VX472L
cols.setParent(gridDatatable);
// create filters inside AuxHeads
Auxhead auxhead1 = new Auxhead();
// create a line with the same number of AuxHeaders as Columns we have
for (int indexColumn = 0; indexColumn < columnsList
.size(); indexColumn++) {
if (columnsList.get(indexColumn).getVisible()) {
// i have definned the diferent Auxheader with a patron factory
Auxheader auxheader = gridDatatableFilterFactory.generateFilter(
columnsList.get(indexColumn).getTerms().getType(),
columnsList.get(indexColumn).getTerms().getKey());
auxheader.setParent(auxhead1);
}
}
// set the Auxhead line between col names and rows
auxhead1.setParent(gridDatatable);
// we add the rowrender for print the rows
gridDatatable.setRowRenderer(
new DatatableRowRender(columnsList, gridDatatableCellFactory));
search();
Thank you in advance, regards.
I created a report with dynamic columns using dynamic reports. If any column in the last row is overflows then the only the overflowing column is stretched and printed on next page. Rest of the columns is not stretched.
The printed report is look like this:
Following section of code is used for creating report with dynamic columns.
JasperReportBuilder jasperReportBuilder=DynamicReports.report();
for(Field field:fields){
for (Entry<String, String> entry : dynamicTableColumns.entrySet()) {
if ( entry.getKey().equals(field.getName())){
jasperReportBuilder.columns(DynamicReports.col.column(entry.getValue(), field.getName().toString(), DynamicReports.type.stringType()).setStretchWithOverflow(true));
}
}
}
I haven't seen any option to set the column's stretch type as RELATIVE_TO_TALLEST_OBJECT. Is there any other way to fix this ?
Setting detail's split type as 'PREVENT' will prevent the row from stretching to next page and move the entire row to next page.
jasperReportBuilder.setDetailSplitType(SplitType.PREVENT);
I'm trying to create a program that searches a known file path for some files. If the search finds the file, I'd like for the program to update a JTable so that it removes that file from the table.
The point is for the table to display files that aren't yet in this certain folder.
edit: "Philly" and "L2" columns are server names. The rows are workstations that are on those servers. The two relate such that when the work has been completed on the workstations, the person who has completed that work takes a screen shot with "Snipping Tool", which is then saved as a .PNG file in a designated folder. The files are saved like... If server 1, workstation 1 was completed, it would be saved as "1-1 MyInitials.PNG" inside of the designated folder.
The idea of using an automatic TimerTask is a great idea, although I'm wholly unfamiliar with it.
You could use the DefaultTableModel of the JTable to search what is in table for a file name match.
Iterate through the table rows and read the value within the cell
column that contains the file name. You can use the the
DefaultTableModel#getRowCount() method and the
DefaultTableModel#getValueAt() methods for this.
Once you have found a match you would like to remove from table then
you can use the DefaultTableModel#removeRow() method.
A method to do this sort of thing might look something like this (Not Tested):
public void removeIfExist(JTable yourJTable, String fileName) {
// Get Table Model
DefaultTableModel dtm = (DefaultTableModel) yourJTable.getModel();
// Get Table Row Count
int rowCount = dtm.getRowCount();
// Assuming file names are in column 1
// and not in column 0.
int fileNameColumn = 1;
// Iterate through each table row and get the String
// value for what is within the row cell of column 1.
for (int i = 0; i < rowCount; i++) {
// Grab the string value in column 1 of current row.
String stringValue = dtm.getValueAt(i, fileNameColumn).toString();
// Is the cell's String value the same as the file name?
// If you want to ignore letter case for comparing then
// use equalsIgnoreCase() instead of equals().
if (stringValue.equals(fileName)) {
// Yes it is so remove the row from JTable.
dtm.removeRow(i);
// Found a match so no need to check
// further. Get out of loop.
break;
}
// No it's not so check the cell in next
// table row (if there is one).
}
}
You can of course modify this method to handle a list of file names instead of one file name at a time. Again, the code above is not tested and is just real quick off the top of my head but I think it gives you an idea of how it can be done.
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
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