How Do I React to the Scenario Where There Are No Records in the View? (Magic xpa 3.x)
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThXN&feoid=00ND0000005rAjf&refid=0EMD0000000JHie)
Often, either because there is no data or because the data doesn’t match the search criteria, the end user will end up in a situation where there are no records in the data view. In this circumstance, the user is confronted with a blank screen, and the user may be confused about what to do next. This section will discuss some of your options for handling this situation.
The first question you need to answer is whether this screen is designed simply to list records, or to allow both listing and modifying of records. Commonly, “list” screens are designed to allow easy searching of data, but do not have enough fields nor the correct record locking to allow the records to be modified. On the other hand, some list screens are designed to be multi-purpose screens. The answer to what to do with an empty data view is different for each of these scenarios, so they will be listed separately.
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThXN&feoid=00ND0000005rAjf&refid=0EMD0000000JHig)
In a list-only screen, the records will never be edited on the screen itself. A list of data will be shown, but the data will probably be in read-only mode, with no transactions opened and no locking. Options will probably be limited, so the Options->Modify or Edit->Create Line command will not be available from the overhead menu.
To create a record in this scenario requires that there be something besides the built-in Magic xpa edit commands. Often this is done by putting Add, Modify, and Delete buttons on the form, or on the context menu. As you can see in this example, the same shortcut keys can be used.
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThXN&feoid=00ND0000005rAjf&refid=0EMD0000000JHio)
To disable the Modify and Delete buttons when there is no record, the Enabled property is set to Not(EmptyDataview(0). This makes it obvious to the end user that Add is the only command that will work when no records are currently available.
Some screens are multi-purpose, and can be used to both list and modify data. Users who have been trained can cycle between Query, Modify, Locate, and Range mode just by keystroke, or by using options from the overhead Edit or Options menus. Push buttons can be set to perform the same functions. These screens can be quite powerful and allow for fast data entry.
However, some confusion can exist when the screen is empty. In this case, the screen is in Query mode, and pressing F4, or selecting Edit->Create Line, will not work until the screen is set to Modify mode.
![](/PublicKnowledge/servlet/rtaImage?eid=ka2D0000000ThXN&feoid=00ND0000005rAjf&refid=0EMD0000000JHik)
One way to handle this is to again use events to capture the default shortcut keys, and also set them to push buttons. This time, however, the Internal event, Modify Records, is raised before the Create Line event. In this example, it is only raised if the task is in Query mode.
One issue exists in older programs that have been around for awhile. In older versions, an empty data view automatically reverted to Create mode. The end users might be used to this behavior, or there may be program logic that expects it.
In this case, you can allow the program to behave in the older style, by setting: Task Properties->Data->Allow empty dataview to No. When you do this, the task will be in Create mode when no records are found.
The Online and Rich Client Samples projects (program DV16 and RDV16)