Creating a Data Source Gadget
A data source is a gadget that manages an IliTable object. The following code sample shows how a data source can be created and set up to manage a memory table:
IlvDisplay* display;
IlvGadgetContainer* panel;
...
// Create a data source gadget.
IliDataSource* ds = new IliDataSource(display,
IlvPoint(10, 10));
// Create and define a memory-table.
IliMemoryTable* tbl = new IliMemoryTable(display);
tbl->lock();
tbl->appendColumn(“Id”, IliIntegerType);
tbl->appendColumn(“Name”, IliStringType);
// Assign the memory-table to the data source.
ds->setTable(tbl);
tbl->unLock();
// Put the data source in a panel.
panel->addObject(ds);
panel->setObjectName(ds, “EMP”);
Data Access provides the following subclasses of the IliDataSource class:
-
IliMemoryDataSource—this class instantiates an IliMemoryTable.
-
IliSQLDataSource—this class instantiates an IliSQLTable.
The only difference between these two classes and their base class is that they automatically instantiate the corresponding type of table. These two subclasses are provided for convenience, however, the IliDataSource class can manage any type of IliTable object.
Another slight difference between these subclasses and their base classes is that each subclass has a specific bitmap that appears in Views Studio. |