Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2002, 05:45 AM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default small TDBNavigator question

Hi,

can anybody tell me if it's possible to make the insertbutton on a TDBNavigator append rather then insert?

Big thanx for any help.

Greetz,
Ted

PS: don't forget to accept this reply as a correct answer (if it IS a correct answer
Reply With Quote
  #2  
Old 01-07-2002, 05:57 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: small TDBNavigator question

I think you may need to override the BtnClick method in
order to do this even though it has a OnBeforeAction event.
<tt>
type
TMyDBNav = class(TDBNavigator)
public
procedure BtnClick(Index: TNavigateBtn); override;
end;

procedure TMyDBNav.BtnClick(Index: TNavigateBtn);
begin
begin
if (DataSource <> nil) and (DataSource.State <> dsInactive) then
begin
if not (csDesigning in ComponentState) and Assigned(FBeforeAction) then
FBeforeAction(Self, Index);
with DataSource.DataSet do
begin
case Index of
nbPrior: Prior;
nbNext: Next;
nbFirst: First;
nbLast: Last;
// Change this line:
// nbInsert: Insert;
nbInsert: Append;
nbEdit: Edit;
nbCancel: Cancel;
nbPost: Post;
nbRefresh: Refresh;
nbDelete:
if not FConfirmDelete or
(MessageDlg(SDeleteRecordQuestion, mtConfirmation,
mbOKCancel, 0) <> idCancel) then Delete;
end;
end;
end;
if not (csDesigning in ComponentState) and Assigned(FOnNavClick) then
FOnNavClick(Self, Index);
end;
</tt>
Reply With Quote
  #3  
Old 01-07-2002, 09:13 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: small TDBNavigator question

Though i think the answ by mr baseball is very correct (though i havent tried it) but is also a bit complex which might not be liked by you so another bypassing sort of way is in the table 's after insert event you put the following two codes

suppose the dbnavigator is linked to table1 through datasource then in the afterinsert even of table1 enter


table1.cancel;
table1.append;

it will definately work and user will never know what you have done., and all the inserted records will appear in the last of the table only and not in between which is ofcourse sometime confusing for some new data entry operators.


i do hope it helps and if it does then do click on the accept button above
Reply With Quote
  #4  
Old 01-07-2002, 10:38 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: small TDBNavigator question

digitiger, that is an excellent answer.

We know not his reasons for wanting append .vs insert. We
know not his database, it makes a difference because on SQL
tables, insert and append do essentially the same thing.

I think overall, the developer would be better off writing
a DBNavigator that has BOTH the inset and append buttons.
Reply With Quote
  #5  
Old 01-07-2002, 02:41 PM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default RE: small TDBNavigator question

i'm using a sybase database and a table in a grid. i have an ordertable, and a orderline table, which is shown on the orderform. my main problem was, that - although i was using an index - the inserted record appeared in the middle (or at the point where the record pointer was at that exact moment), and not at the end of the grid. It was a bit confusing to the end-user, cause the record appeared at the end if the post button was pressed. Both your answers where right, but i created the component. I extended the feature a little more with a property to choose between append and insert and using an if-clause on the nbInsert-case. it works :0) thank you both for your help.


Greetz,
Ted

PS: don't forget to accept this reply as a correct answer (if it IS a correct answer
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:38 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.