Sample Documents For Tables
This section includes code samples for both persistent and virtual DataTable objects:
Samples for a persistent DataTable object
This section includes sample files that use a persistent DataTable as an example. You could create a Table that displays salary information by using similar code.
The same DataTable is displayed as a Calendar on the second tab:
To view samples for a specific file type, see:
- Sample DataTable definition
- Sample Table View definition
- Sample Hierarchy View definition
- Sample Calendar View definition
- Sample Procedure
- Sample App UI file
Sample DataTable definition
DATATABLE dtSalary Columns ID, Name, Category, Type, Salary, Wage, Entity, Active, Start_Date, Location, Manager, Vacation_Entitlement
Sample Table View definition
Columns ID, Name, Start_Date, Type, Salary, Wage, Category, Entity, Active, Location
ColumnWidth 100
Protect Category
ApplyUserPreferences FALSE
Action "Submit", "Resources/images/submit.png", "Upload dtSalary", "", TOOLBAR
SystemAction Filter, "", "", ""
SystemAction GroupBy, "GroupBy", "", ""
SystemAction ExporttoExcel, "Export to Excel", "", ""
Action "Clear Table", "Resources/images/reset-import.png", "DELETE DATATABLEROWS FROM dtSalary", "", TOOLBAR
Action "Close", "Resources/images/exit.png", "SHOW RETURN", "", TOOLBAR
SystemAction ViewLayout, "Layout", "", ""
SystemAction PrintPreview, "", "", "Print Preview"
Sample Hierarchy View definition
Columns SymName,SymDesc,Parent,SortOrder,BalanceType,Notes
NameColumn SymName
DescriptionColumn SymDesc
ParentColumn Parent
SortOrderColumn SortOrder
SetColumn "SymName", "Description:Symbol Name"
SetColumn "SymDesc", "Description:Symbol Description"
SetColumn "SortOrder", "Description:Sort Order"
ColumnWidth 100
ColumnWidth 200, SymDesc
DefaultDecimals 0
ShowToolbarButtons All
Action "Submit", "", "Upload dtSymbols", "Submit", TOOLBAR
SystemAction Close, "", "", ""
Sample Calendar View definition
DateColumn Start_Date
DescriptionColumn Name
SystemAction Close, "Close", "", ""
Sample Procedure
Create DATATABLE dtSalary using "Salary.lvdtd"
Create DATATABLE dtSymbols using "Symbols.lvdtd"
Download dtSalary
Download dtSymbols
Show DATATABLE dtSymbols USING HIERARCHY "Symbols.lvhvw"
Show UI USING ”Table.lvui"
Sample App UI file
LAYOUTTYPE Tabbed
DATATABLE, dtSalary, TABLE, "Salary.lvtvw", "Tasks", "", ""
DATATABLE, dtSalary, CALENDAR, "EmpStartDates.lvcvw", "Calendar", "", ""
Samples for a virtual DataTable object
This section includes sample files that use a virtual DataTable as an example. You could create a Table that displays a top ten list by using similar code.
To view samples for a specific file type, see:
- Sample DataTable definition
- Sample ImportSpec
- Sample source file for ImportSpec
- Sample Table View definition
- Sample Procedure
Sample DataTable definition
// Define a Virtual Table to display Customer Sales
DATATABLE VIRTUAL
AddColumn STRING, "Customer"
AddColumn STRING, "Industry"
AddColumn STRING, "SalesRep"
AddColumn BOOLEAN, "Preferred", "Default:FALSE"
AddColumn NUMBER, "Value"
Sample ImportSpec
//Description: Imports Sales Data into a Virtual Table
//Specify the source file DataSource TEXT, "Sales.txt", EXTERNAL, "@"
//Set fields in file (1 per field to be processed)
Set Customer, 1
Set Industry, 2
Set Value, 5
Set Preferred, 4
Set SalesRep, 3
Define Customer, MATCH, Customer
Define Industry, MATCH, Industry
Define Value, MATCH, Value
Define Preferred, MATCH, Preferred
Define SalesRep, MATCH, SalesRep
//Set the maximum number of errors before the import is stopped MaxError 0
//Specify a file to record errors ErrorFile "import_errors.txt", EXTERNAL
//Specify a file to log import details LogFile "import_log.txt", EXTERNAL
//Specify Decimal Character DecimalCharacter "."
Sample source file for ImportSpec
Customer A@Finance@Mike Greene@0@200000.00
Customer B@Manufacturing@Mary Brown@0@400000.00
Customer C@Health Care@Mike Greene@1@1200000.00
Customer D@Health Care@John Smith@1@770000.00
Customer E@Manufacturing@Mike Greene@0@100000.00
Customer F@Manufacturing@Mary Brown@0@350000.00
Customer G@Health Care@John Smith@0@280000.00
Customer H@Finance@John Smith@0@230000.00
Customer I@Finance@Mary Brown@0@900000.00
Customer J@Education@John Smith@0@234000.00
Customer K@Education@Mike Greene@1@850000.00
Customer L@Health Care@John Smith@0@330000.00
Customer M@Manufacturing@John Smith@0@560000.00
Customer N@Finance@Mary Brown@1@780000.00
Customer O@Manufacturing@John Smith@0@250000.00
Customer P@Finance@John Smith@0@753200.00
Customer Q@Health Care@Mike Greene@0@634000.00
Customer R@Education@John Smith@0@456000.00
Customer S@Finance@Mary Brown@0@657000.00
Customer T@Manufacturing@Mary Brown@0@230000.00
Sample Table View definition
// Specify columns in the DataTable object to show and their order Columns Customer, Value, Preferred, Industry, SalesRep
//Specify column descriptions to display
SetColumn "Customer", "Description:Customer"
SetColumn "Industry", "Description:Industry"
SetColumn "SalesRep", "Description:Sales Rep"
SetColumn "Value", "Description:Annual Sales"
SetColumn "Preferred", "Description:VIP Customer"
// Sort by highest Sales SortOrder "Value DESC"
// Restrict to show top ten customers VISIBLEROWS 10
Columnwidth 120
SystemAction GroupBy, "GroupBy", "", ""
SystemAction ExporttoExcel, "Export to Excel", "", ""
SystemAction PrintPreview, "", "", "Print Preview"
Action "Close", "Resources/images/exit.png", "SHOW RETURN", "", TOOLBAR
ApplyUserPreferences FALSE
Sample Procedure
//Export Sales Data in Data Area to file RUN EXPORT Sales.lvexp ON SampleDA
// Create a VIRTUAL Data Table Create DATATABLE dtTableMode using "VirtualSalesTable.lvdtd"
// Import Salary Data into Data Table RUN IMPORT "Sales.lvimp" TO dtTableMode
// Present user Salary Data in table mode Show DATATABLE dtTableMode using TABLE "VirtualSalesTableTopTen.lvtvw"