Since my Mobile app list control exceeded local storage when the filter returned a large number of records (no error, the filter just stops working), I needed to decouple the image binary data from the list. I unmapped the image control from the list and removed the binary field from the SQL data source. My list filters now work as expected with a much smaller payload.
When the user taps to view details, I am able to perform an Ajax callback to get the image to be displayed on demand. Here is the code snippet from my xbasic function. This works perfectly and it's very fast.
dim imageData as c = base64EnCode(rs.data("ReceiptImage"))
imageData = "data:image/jpeg;base64," + imageData
js = "$('{dialog.ComponentName}.V.R1.RECEIPTIMAGE').src='" + imageData + "';"
Now I need to go the other way by capturing an image and writing an xbasic function to update the SQL binary field.
From my limited knowledge, I know I can extract the image control src property - data:image/jpeg:base64 and update another hidden field with the encoded image data using java script. I was hoping there is an Xbasic function that can reference the e object of the data bound image control and perform an update command.
Here is the code I started.
Any advise would be greatly appreciated. Thanks.
dim blobfile as b
blobfile = e.dataSubmitted.ReceiptImage ' This is blank even though an image is displayed.
sqlCommand = "Update Job.Expense Set ReceiptImage=:whatReceiptImage WHERE ExpenseID = :whatExpenseID"
args.add("whatReceiptImage",blobfile)
args.add("whatExpenseID",e.dataSubmitted.ExpenseID)
ok = cn.execute(sqlCommand,args )
Note: I am using a data bound image control even though it is not mapped to a field in the database.
When the user taps to view details, I am able to perform an Ajax callback to get the image to be displayed on demand. Here is the code snippet from my xbasic function. This works perfectly and it's very fast.
dim imageData as c = base64EnCode(rs.data("ReceiptImage"))
imageData = "data:image/jpeg;base64," + imageData
js = "$('{dialog.ComponentName}.V.R1.RECEIPTIMAGE').src='" + imageData + "';"
Now I need to go the other way by capturing an image and writing an xbasic function to update the SQL binary field.
From my limited knowledge, I know I can extract the image control src property - data:image/jpeg:base64 and update another hidden field with the encoded image data using java script. I was hoping there is an Xbasic function that can reference the e object of the data bound image control and perform an update command.
Here is the code I started.
Any advise would be greatly appreciated. Thanks.
dim blobfile as b
blobfile = e.dataSubmitted.ReceiptImage ' This is blank even though an image is displayed.
sqlCommand = "Update Job.Expense Set ReceiptImage=:whatReceiptImage WHERE ExpenseID = :whatExpenseID"
args.add("whatReceiptImage",blobfile)
args.add("whatExpenseID",e.dataSubmitted.ExpenseID)
ok = cn.execute(sqlCommand,args )
Note: I am using a data bound image control even though it is not mapped to a field in the database.
Comment