Is it possible to select multiple rows on a tableview then scroll through the the table identifying those rows selected.
Dim jo As JavaObject = TableView1
Dim sm As JavaObject
sm = jo.RunMethod("getSelectionModel",Null)
Dim sm1 As JavaObject
sm1.InitializeStatic("javafx.scene.control.SelectionMode")
sm.RunMethod("setSelectionMode",Array(sm1.GetField("MULTIPLE")))
' the following 3 lines ONLY work in release mode and will select rows 1, 2 and 5
sm.RunMethod("select",Array(1)) ' select row 1
sm.RunMethod("select",Array(2)) ' select row 2
sm.RunMethod("select",Array(5)) ' select row 5
' to add rows from mouse click use ctrl+click otherwise selection is reset
' get selected rows from table as list
Dim l As List
l.Initialize
l.AddAll(sm.RunMethodJO("getSelectedItems",Null))
' display the data in the rows
Dim ss As String = ""
For Each o() As Object In l
For Each o1 In o
If ss="" Then
ss = o1
Else
ss = ss & "-" & o1
End If
Next
Log(ss)
ss=""
Next
...
Try
Dim jo1 As JavaObject = dtprangeFrom
Dim jo2 As JavaObject = dtpRangeTo
Dim sDate1 As String = jo1.RunMethod("getValue", Null)
Dim dDate1 As Long = DateTime.DateParse(sDate1)
Dim sDate2 As String = jo2.RunMethod("getValue", Null)
Dim dDate2 As Long = DateTime.DateParse(sDate2)
Catch
msg.Show("Select date range","Date range error")
Log(LastException)
Return
End Try
Log("Period from " & DateTime.Date(dDate1) & " to " & DateTime.Date(dDate2))
'select row
Dim jo As JavaObject = tblCB
Dim sm As JavaObject
sm = jo.RunMethod("getSelectionModel",Null)
Dim sm1 As JavaObject
sm1.InitializeStatic("javafx.scene.control.SelectionMode")
sm.RunMethod("setSelectionMode",Array(sm1.GetField("MULTIPLE")))
Dim Li As List
Li.Initialize()
For i = 1 To tblCB.Items.Size-1
Log("row selected is " & i)
tblCB.SelectedRow = i
Dim row() As Object = tblCB.SelectedRowValues
Dim DT As Long = DateTime.DateParse(row(1))
Log("Transaction selected is " & row(0) & " " & row(1))
If DT >= dDate1 And DT <=dDate2 Then
'Now select the actual row
Li.Add(i)
Log(i & " is in date range" & DateTime.Date(DT))
End If
Next
For Each j In Li
Log("selecting item row " & j)
jo.RunMethodJO("getSelectionModel",Null).RunMethod("select",Array(j))
Next
'Get selected rows from the table as list
Dim l As List
l.Initialize
l.AddAll(sm.RunMethodJO("getSelectedItems",Null))
'Display the data in the rows
Dim ss As String = ""
For Each o() As Object In l
For Each o1 In o
If ss = "" Then
ss=01
Else
ss = ss & "-" & o1
End If
Next
Log(ss)
ss = ""
Next
' in globals
Dim nash As jInvokeNashorn ' in libraries under jscriptengine
Dim scr As String
scr = $"
load("fx:base.js")
load("fx:controls.js")
load("fx:graphics.js")
function selectRows(table,from,to){
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE)
for each(i in table.items){
if (i[0] >= from && i[0] <= to){ //compare col 0 to value
table.getSelectionModel().select(i)
}
}
}
function selectedPrint(table){
table.getSelectionModel().getSelectedItems().forEach(function(aa){print(aa[0],"-",aa[1])})
}
function getSelected(table){
return table.getSelectionModel().getSelectedItems()
}
"$
nash.InitInvocable(scr)
nash.Invoke("selectRows",Array(TableView1,3,6))
nash.Invoke("selectedPrint",Array(TableView1))
Log(nash.Invoke("getSelected",Array(TableView1)))
scr = $"
load("fx:base.js")
load("fx:controls.js")
load("fx:graphics.js")
function selectRows(table,from,to){
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE)
for each(i in table.items){
if (i[0] >= from && i[0] <= to){ //compare col 0 to value
table.getSelectionModel().select(i)
}
}
}
function selectedPrint(table){
table.getSelectionModel().getSelectedItems().forEach(function(aa){print(aa[0],"-",aa[1])})
}
function getSelected(table){
return table.getSelectionModel().getSelectedItems()
}
"$
nash.InitInvocable(scr)
nash.Invoke("selectRows",Array(tblCB,1,6))
nash.Invoke("selectedPrint",Array(tblCB))
Log(nash.Invoke("getSelected",Array(tblCB)))
function selectRows(table,from,to){
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE)
for each(i in table.items){
if (i[0] >= from && i[0] <= to){ //compare col 0 to value
table.getSelectionModel().select(i)
}
}
}
function selectRows(table,col,from,to){
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE)
for each(i in table.items){
if (i[col] >= from && i[col] <= to){ //compare col.value to limits
table.getSelectionModel().select(i)
}
}
}
function selectedPrint(table){
table.getSelectionModel().getSelectedItems().forEach(function(aa){print(aa[0],"-",aa[1])})
}
function selectRows(table,from,to){
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE)
for each(i in table.items){
if (i[1] >= from && i[1] <= to){ //compare col 0 to value
table.getSelectionModel().select(i)
}
}
}
nash.InitInvocable(scr)
Try
Dim jo1 As JavaObject = dtprangeFrom
Dim jo2 As JavaObject = dtpRangeTo
Dim sDate1 As String = jo1.RunMethod("getValue", Null)
Dim dDate1 As Long = DateTime.DateParse(sDate1)
Dim sDate2 As String = jo2.RunMethod("getValue", Null)
Dim dDate2 As Long = DateTime.DateParse(sDate2)
Catch
msg.Show("Select date range","Date range error")
Log(LastException)
Return
End Try
nash.Invoke("selectRows",Array(tblCB,dDate1,dDate2))
nash.Invoke("selectedPrint",Array(tblCB))
Log(nash.Invoke("getSelected",Array(tblCB)))