0

Using HTML Lightswitch

The application I'm working on is for our inventory team to scan barcode's off devices. I have a Browse screen with a local string property used as my search box (textbox) that's binded to a query. This search box is where a barcode scanner inputs the text. The barcode scanner we use automatically presses 'Enter' after the text has been entered. This causes the binded local property to execute the query. I'm then displaying the results on screen as visual validation for the user. At this point, the scanned text is still in the search box. I would like to clear the searchbox text OR highlight the text so my users can scan the next device without interacting with the computers mouse/keyboard/touchscreen.

Ideal workflow for user:

  1. Scan barcode
  2. Visually validate returned results
  3. Scan barcode again

Updated above post.

HiTech
  • 913
  • 1
  • 16
  • 34
  • What device is being used to scan? If Motorola, and your app runs on a WindowsCE device, I can steer you to some code. – B. Clay Shannon-B. Crow Raven Mar 16 '16 at 22:02
  • Depends on your barcoder, first off, some barcoders dont send line feeds so went "auto" press a button if you need them to, so for example, I was scanning tape codes that have a format of ZZ9999L3 so, once text entered matches that, or if it doesnt, reject it, I can send it on for searching.. on receiving of the result, you can clear the text then, or, clear it at the sending of the search if you're appending to a data set. – BugFinder Mar 16 '16 at 22:07
  • I'm using a usb powered handheld barcode scanner. It automatically sends line feed (Enter key?) after each scan. -Note: My application is using Lightswitch HTML – HiTech Mar 16 '16 at 22:24
  • If possible, please can you post a designer screen shot of your current LightSwitch screen as this should make it easier to provide an appropriate example. – Chris Cook Mar 20 '16 at 14:44
  • @ChrisCook I'm not sure how the screen shot would help unless you're looking for an explanation of everything in the screen shot. – HiTech Mar 22 '16 at 22:47
  • Seeing the structure of your screen could help to confirm a few points and should allow an answer to be presented using your chosen control names etc. – Chris Cook Mar 22 '16 at 23:03
  • I updated my post to make my request a bit more clear. @ChrisCook – HiTech Mar 23 '16 at 21:06
  • @HiTech Thanks - just to double check, was the query added using the 'Add Data Item\Query' option and is its query parameter binding set to the local property that is also data bound to your search textbox? Also, do you have your query's 'support paging' option ticked? – Chris Cook Mar 25 '16 at 11:17
  • @HiTech Also, what type of screen are you using (Browse/View/AddEdit) and does your query only ever return one result? – Chris Cook Mar 25 '16 at 20:04
  • @ChrisCook My post answers your question about the query/local property. As far as I know, that's the only way you can add a query to your screen. What exactly does the paging option have anything to do with my post? Yes, paging is turned on. Also, I'm using a browse screen. Updating my post again to reflect this. – HiTech Mar 28 '16 at 21:23
  • @HiTech Thanks - I've added a quick answer based on these details – Chris Cook Mar 29 '16 at 02:05

1 Answers1

1

Probably the simplest way of tackling this is to add two local barcode string properties to your screen.

One of these two local properties would be bound to the query's parameter but not placed on the screen (Barcode_Parameter).

The other local property would simply be placed on the screen as a TextBox (Barcode) as shown in the following screen-shot:

Example screen design

You would then implement code along the following lines in the postRender of the TextBox:

myapp.ScanDevice.Barcode_postRender = function (element, contentItem) {
    var screen = contentItem.screen;
    contentItem.dataBind("value", function (value) {
        if (value) {
            screen.setBarcode_Parameter(value);
            screen.setBarcode("");
        }
    });
};

This code will only update the local property that is bound to the query parameter (Barcode_Parameter) when a string is supplied and at the same point will clear the local property bound to the TextBox on the screen (Barcode).

The following shows the cursor placed on the cleared TextBox after the string 123456 has been entered and followed by a carriage return:

Running example

Chris Cook
  • 2,821
  • 1
  • 20
  • 32
  • Money. As of right now it works perfectly! That's a neat little trick. Thank you! I'll report back if i have any issues but in the meantime +1 and accepted! – HiTech Mar 29 '16 at 02:17