Data Access User Manual > Rogue Wave Views Data Access Common Framework > Data Sources and Gadgets > Data Sources > Managing Rows in a Data Source
 
Managing Rows in a Data Source
Once a data source gadget has been defined and gadgets have been connected to it, the row management member functions of the data source can be used. These row management functions differ from the IliTable row management functions in that they are based on the concept of a current row. Changing the current row of a data source has a direct result on the user interface. The IliTable row management functions should be used when you want to manage rows without changing the current row in the user interface. Changing the current row means moving to another row. With regard to editing the values in a row (current or not), the user interface is updated in both cases. See Managing Rows in a Table.
From the end user’s point of view, Data Access provides an IliDbNavigator gadget that connects to a data source. With this gadget, the end user can perform actions on the data source.
An IliDbNavigator Gadget and the API Member Functions that It Calls
Each button in the IliDbNavigator calls the corresponding member functions in IliDataSource directly.
If the table object managed by the data source is a two-tier table (for example, an IliSQLTable), the select member function can be used to re-evaluate the SQL table query.
The “goto” set of member functions enable you to move the current row of the data source. You can move to any row using the gotoPrevious, gotoNext, gotoFirst, gotoLast, gotoRow. The gotoRow member function takes a row index parameter.
When the current row of a data source changes, the value displayed by any gadget connected to the data source (for example, entry fields), is automatically adjusted.
If you want to modify a row in the underlying table of a data source, you can proceed in the following way:
IliDataSource* ds;
...
// We want to modify the 2nd row.
ds->gotoRow(1);
// Make any changes to the columns of the data source.
ds->setValue(“Name”, IliValue(“Smith”));
...
// Validate changes.
if(!ds->validate())
IlvPrint(“Update failed”);
The setValue member function is used to modify a value contained in the data source buffer. The data source buffer retains the changes until the validate member function is called. When there are changes pending in a validation, the isInputModified member function returns true.
During the period of time that it takes for the isInputModified member function to return true on a data source, any pending changes can be canceled using the cancel member function.
In all situations, the underlying table is modified only when validate is called, not each time the setValue member function is called.
The following code sample shows how a new row can be inserted:
IliDataSource* ds;
...
// We want to insert a new row.
ds->startInsert();
// Assign values to the columns of the data source.
ds->setValue(“Id”, IliValue(32));
ds->setValue(“Name”, IliValue(“Jones”));
...
// Validate insertion.
if(!ds->validate())
IlvPrint(“Insert failed”);
The main difference between this example and the previous one is that the startInsert member function is used instead of using the gotoRow member function to move to an existing row.
Note: You can disable the insertion through a data source by calling the enableInsert member function with the parameter set to false.
The deleteCurrentRow member function can be used to remove the current row.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.