Rave - Data Connections
I need to refresh my dataviews dynamically. How would I do that?
Dataviews can be refreshed dynamically quite easily using the CreateFields method. The CreateFields can be used to query the DataView and return a list containing the fields that will be deleted and also a list of fields that will be changed. This method takes four parameters. The first is the dataview that you want to refresh. The second parameter is a string list that would be passed in to hold the list of fields that will be deleted. The third parameter is a string list that would be passed in to hold the list of the fields that will be changed or replaced. The fourth parameter is a boolean parameter that specifies whether to update the fields or just return the information in the specified string lists.
The example listed below doesn't bother to query the user for any change information but simply refreshes the dataview without any user interaction. It should also be noted that the following code works beginning with Rave 4.0. If you need to do this with Rave 3.0 then you will need to rename TRaveBaseDataView to just TRaveDataView.
Delphi Example:
uses RVData; procedure TForm1.butnDesignClick(Sender: TObject); var DataView: TRaveBaseDataView; begin RaveProject1.Open; With RaveProject1.ProjMan do begin Dataview := FindRaveComponent('Dataview1',nil) as TRaveBaseDataView;// get the dataview to refresh CreateFields(DataView, nil, nil, true); // refresh the dataview end; { with } if RaveProject1.Design then begin if MessageDlg('Save Changes?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin RaveProject1.Save; end; end; end;
C++Builder Example:
void __fastcall TForm1::butnDesignClick(TObject *Sender) { TRaveBaseDataView* DataView; TRaveProjectManager* pm = RaveProject1->ProjMan; RaveProject1->Open(); // get the dataview to refresh DataView = dynamic_cast(pm->FindRaveComponent("Dataview1",NULL)); // refresh the dataview CreateFields(DataView, NULL, NULL, true); if (RaveProject1->Design()) { if (MessageDlg("Save Changes?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes) { RaveProject1->Save(); }// if }// end }