Specify an Instruction Help Text in the Grid
by
, 27-Jan-2011 at 03:00 AM (5101 Views)
Imagine you are an end-user and you have the order entry view open. The screen is empty, what to do now? Of course you need to select an existing order or create a new order before you can go the data entry grid and enter order detail lines, but what if you do not know this? Wouldn't it be nice when the screen gives you some hints and tips? For example a text like: "You can enter this order detail grid after you selected an existing order or created a new order in the top half of the screen."? I bet you will say YES I want this! How do I do this? The solution consist of two options. One is turn off the grid cells/lines when there is no data. You can do this by setting the property pbDrawGridForEmptySpace.The second part is setting the property psNoItemsText.Code:Object oOrderDtl_Grid is a cDbCJGrid Set pbDrawGridForEmptySpace to FalseThe empty lines prior to the text and the break of the text in the text are achieved by adding a couple of character(13) instructions to the string.Code:Set psNoItemsText to "You can enter this order detail grid after you selected an existing order or created a new order in the top half of the screen."Is this all? Yes and no. Yes, if you are satisfied you can keep it this way. No if you realize that you can also change the text when situation changes. For example if there is an existing order record but no detail lines or even when there is an existing order - without detail lines - that you are modifying.Code:Set psNoItemsText to (Character (13) + Character (13) + "You can enter this order detail grid after you selected an existing order" + Character (13) + "or created a new order in the top half of the screen.")How do I do that? I suggest you make use of an idle timer. If your view - like the order entry view - already has one related to the grid enhance that one else add a new one.Code:Object oIdle is a cIdleHandler Procedure OnIdle Delegate Send OnIdle End_Procedure End_Object Procedure OnIdle Send EnableObjects End_Procedure Procedure EnableObjects Boolean bChanged bRec bInEdit Handle hoServer hoDataSource Integer iRows Get Server to hoServer Get Should_Save of hoServer to bChanged Get HasRecord of hoServer to bRec Set Enabled_State of oOrderDtl_Grid to (not(bChanged) and bRec) Set Enabled_State of oPrintBtn to bRec Get IsEditMode of oOrderDtl_Grid to bInEdit If (not (bInEdit)) Begin Get phoDataSource of oOrderDtl_Grid to hoDataSource Get RowCount of hoDataSource to iRows Set pbDrawGridForEmptySpace of oOrderDtl_Grid to (bRec and iRows) If (bChanged) Begin Set psNoItemsText of oOrderDtl_Grid to (Character (13) + "Save the order and then click here to add order details") End Else Begin If (bRec) Begin Set psNoItemsText of oOrderDtl_Grid to (Character (13) + "Click here to add order details") End Else Begin Set psNoItemsText of oOrderDtl_Grid to (Character (13) + Character (13) + "You can enter this order detail grid after you selected an existing order" + Character (13) + "or created a new order in the top half of the screen.") End End End End_Procedure