Working Preview Pane

Description

The Working Preview is like the Live Preview in that it shows an actual working version of your grid.

Unlike the Live Preview, doesn't require the Alpha Anywhere application server to be turned on. Instead, the Working Preview talks directly to Xbasic using an Alpha Anywhere protocol, not the http protocol. The Working Preview has two main benefits, speed and the ability to easily debug into your Xbasic event handlers. If you want an example of how you might go about doing this see the example below or watch this "Working Preview" video.

  1. Go to Component Type and check Updatable to make a grid you can update.

  2. In the Grid > Data Source page Select .dbf Tables .

  3. Under Grid > Query(DBF) add the customer table from Alpha Sports.

  4. Go to the Grid > Fields page and select the first four fields ( Customer_id, Firstname, Lastname,and Companyin this case) in the Available Fields list and move them to the Selected list on the right.

  5. Now go to Working Preview and you will see a full working copy of your grid that you can interact with.

  6. Now go back to Grid > Fields and select the Companyfield under the Selected list. Move over to Field Properties and select Validation Xbasic and click the button at the end of the Validation Xbasic row.

    Go to Validation Xbasic to alter the Xbasic script .
  7. In the Validation Xbasic for: Dialog that loads add the following code. This states that if the Company is blank and if the Lastname is Smith than we will generate an error message that says the 'Company can not be blank'. Put a debug(1) in your script to run the debugger.

    function validate_Company as p (e as p)  
    if e.data.Company = "" then  
    debug(  1  )  
        if e.data.Lastname = "Smith" then 
            validate_Company.hasError = .t. 
            validate_Company.errorText = "Company cannot be blank." 
        end if 
    end if 
        end function
  8. Now go back to Working Preview and Choose the Lastname field and write 'Smith' over an existing name, then go the Company field on the same row and erase the company name. You should end up with something like the image below.

  9. Still in Working Preview , hit the Submit at the bottom of your Grid, since your grid is updatable it should have a submit button all ready to go. Go back and look at the fields you changed. You should see the debugger open and also an error warning in the Company field whose name you erased. In the debugger you should be able to hover over the variables that cause the error warning you made and see that they correspond to the changes you made. For example by hovering over Lastname you will see that you entered 'Smith' as the last name.

  10. Remember to remove your debug statement before you look at your grid in Live Preview. Also you will need to turn on the Alpha Anywhere application server. If you don't like the working preview you can go to Options Preferences and turn off the working preview from there.