Another nooby question for the community ^^
I have this datatable in my page, wich I managed to visualize the selected row in this way:
The table is filled via a sql query that return the product name and the price.
Code is the following:
At this point I'm stuck in getting any output about WHICH row is currently selected. How to let know to B4J?
I was thinking about create a sort of hidden object (like a paragraph) in the html and write there one of the row field, so I can retrieve it in B4J by calling the text method, but I think there's a more elegant solution out there...can you help me finding it?
I also checked the DBUtils example, but I couldn't understand it
I can see it does something similar to what I want to achieve (it gets the selected row and change the value of a combobox accordingly), but I really tried to reverse-engineer the code without success
I have this datatable in my page, wich I managed to visualize the selected row in this way:
JavaScript:
$('#tabproduct tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
$('#tabproduct tbody tr.selected').removeClass('selected');
$(this).addClass('selected');
}
} );
} );
The table is filled via a sql query that return the product name and the price.
Code is the following:
B4X:
Sub FillTable(jq As JQueryElement, rs As ResultSet) 'Popola una datatable con gli elementi di una query SQL
Dim data As List
data.Initialize
Do While rs.NextRow
Dim row As List
row.Initialize
For a = 0 To rs.ColumnCount - 1
Dim val As String = rs.GetString2(a)
Select a
Case 0
row.Add(val)
Case 1
Dim prezzo As Float = val
Dim prezzoeuro As String = "€ " & NumberFormat(prezzo, 1, 2)
row.Add(prezzoeuro)
End Select
Next
data.Add(row)
Loop
rs.Close
jq.RunMethod("dataTable", Array As Object(CreateMap("aaData": data, "bDestroy": True, "bFilter": True, _
"bPaginate": False, "sScrollY": "200px", "bSort": False, "bInfo": False)))
End Sub
At this point I'm stuck in getting any output about WHICH row is currently selected. How to let know to B4J?
I was thinking about create a sort of hidden object (like a paragraph) in the html and write there one of the row field, so I can retrieve it in B4J by calling the text method, but I think there's a more elegant solution out there...can you help me finding it?
I also checked the DBUtils example, but I couldn't understand it
I can see it does something similar to what I want to achieve (it gets the selected row and change the value of a combobox accordingly), but I really tried to reverse-engineer the code without success