Hi
I'd like to use this inside a custom view. I'm trying to create an editable tableview that can have a maximum of 20 columns. So I declared
Private tcCol(19) As TableColumn
inside
class globals and I'm getting an error on this line when I compile. Yes, in your example this is inside Process_Globals and classes
I fear that perhaps my approach might not work.
In my own SetColumns method I added...
If bIsReport = True Then
'extend this tableview
tveThis.InitializeByExtending(TV)
tveThis.Items.Initialize
tveThis.SingleCellSelection = True
'set up the extended editor for each column
For colCnt = 0 To colTot
colMap = Columns.GetValueAt(colCnt)
colName = colMap.get("name")
colWidth = colMap.get("width")
colTag = colMap.Get("tag")
colVisible = colMap.Get("visible")
' set columns widths, default is 150
If colWidth = "-1" Then colWidth = 150
'set the cell factory
tcCol(colCnt) = tveThis.GetColumn(colCnt)
tcCol(colCnt).SetCellFactoryWithMouseEvents("Col" & colCnt)
tcCol(colCnt).Width = colWidth
tcCol(colCnt).Resizable = True
'initialize the textboxes
tfEditor(colCnt).Initialize("Editor" & colCnt)
Next
tveThis.SetRowEventsListener("Row")
End If
And then added the respective handlers
Sub ExtendedMousePressed(EventData As MouseEvent,idx As Int)
Dim Cell As TableCell = Sender
Dim FirstTimeInCell As Boolean = PrevRow <> Cell.Row.Index Or PrevCol <> 0
If FirstTimeInCell Then
PrevRow = Cell.Row.Index
PrevCol = 0
Else If EditedCell = Null Then
'Marks the cell and raises a CellFactory event to replace the text of the city name by a TextField
EditedCell = Cell
EditedCell.Tag = Cell.Row.Index
Cell.Update
'Sets the focus on the editor (requires to consume the event first)
EventData.Consume
tfEditor(idx).RequestFocus
End If
End Sub
Sub ExtendedCellFactory(Cell As TableCell, Empty As Boolean, idx As Int) As Object
'No need to do anything for empty cells
If Empty Then Return Null
'If the cell is marked, returns a TextField to edit the city name
If Cell = EditedCell Then
If Cell.Row.Index <> EditedCell.Tag Then
'If the cell was recycled after a scrolling, cancel the operation
EditedCell = Null
Else
tfEditor(idx).Text = Cell.Item
Return tfEditor(idx)
End If
End If
Return Cell.Item
End Sub
'extended tableview
Sub Col0_MousePressed(EventData As MouseEvent)
ExtendedMousePressed(EventData,0)
End Sub
Sub Col0_CellFactory(Cell As TableCell, Empty As Boolean) As Object
Return ExtendedCellFactory(Cell,Empty,0)
End Sub
Sub Editor0_Action
'Commits the change
Update_Col(0)
End Sub
So the idea is to have each Col0 - Col19 respective methods. The compilation is going well and stops at the definition...
B4J Version: 6.00
Parsing code. (1.69s)
Compiling code. (0.98s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
B4J line: 93
Private tcCol(19) As TableColumn
javac 1.8.0_152
src\b4j\Mashy\PenNPaper\editabletv.java:1229: error: constructor ColumnWrapper in class ColumnWrapper cannot be applied to given types;
_tccol[i0] = new flm.b4j.tableviewextended.ColumnWrapper();
^
required: TableColumn<Object[],?>
found: no arguments
reason: actual and formal argument lists differ in length
That's exactly the line with
Private tcCol(19) As TableColumn
Is there something I'm missing? Can you please advise?
Thanks