Subject Re: IB_Grid - multiple deletion
Author Marco André
HI Ramil,

Thank you again, but I dont know how to fire the event to call the
procedure. Can you send me a full example? The question is: I have a
IB_Grid, with multiple row selected and want to delete those. I tried
the code you sent, but the event doesnt fire at all... I created a
TActionList (inside I also created a New Standard Action -
TIB_ActionDelete1, with the Datasource property filled).

Here is what i have at the moment:

procedure TdmDados.IB_ActionDelete1Execute(Sender: TObject);
var
i, SelCount: Integer;
TempStrings, SelBookMarks: TStringList;
begin
SelBookMarks:=TStringList.Create;
TempStrings:=TStringList.Create;
try
TIB_Query(Sender as TIB_CustomActionUpdate).SelectedBookmarks
(SelBookMarks);
SelCount:=SelBookMarks.Count;
if SelCount>0 then
begin
TempStrings.Clear;
TempStrings.AddStrings((Sender as
TIB_CustomActionUpdate).DataSource.Dataset.ConfirmDeletePrompt);
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.ConfirmDeletePrompt.Clear;
try
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.ConfirmDeletePrompt.Add(
'Want delete selected rows ('+ IntToStr(SelCount)+') ?');
// RefInfoProps.Caption it's my own variable
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.DisableControls;
TIB_Query(Sender as
TIB_CustomActionUpdate).IB_Transaction.AutoCommit:=False;
try
for i:=0 to Pred(SelCount) do
begin
if i=1 then
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.ConfirmDeletePrompt.Clear;
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.Bookmark:=SelBookMarks[i];
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.Delete;
end;
TIB_Query(Sender as TIB_CustomActionUpdate).SelectAll
(False);
finally
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.EnableControls;
TIB_Query(Sender as
TIB_CustomActionUpdate).IB_Transaction.AutoCommit:=True;
TIB_Query(Sender as
TIB_CustomActionUpdate).IB_Transaction.CommitRetaining;
end;
finally
(Sender as
TIB_CustomActionUpdate).DataSource.Dataset.ConfirmDeletePrompt.AddStri
ngs(TempStrings);
end;
end
else IB_ActionDelete1.ExecuteTarget(Sender);
finally
TempStrings.Free;
SelBookMarks.Free;
end;
end;

What shoul I do to trigger this event at the IB_Grid? When I click on
IB_UpdateBar (delete button), only one record selected is deleted and
IB_ActionDelete1Execute is never fired. What is wrong?

I dont you if you understand...Its a little confusing... And sorry
for the bad english.

Thank you!

[]s, Marco André

--- In IBObjects@yahoogroups.com, Ramil <khabibr@m...> wrote:
> Sorry, DataSet is also my variable. I have listed code in my common
> inheritable data edit form.
> Use (Sender as TIB_CustomActionUpdate).DataSource.Dataset instead of
> DataSet.
>
> You must assign DataSource property of IB_ActionDelete action
before.
> Good luck!
>
> Glad to help,
> Ramil
>
> > Hi Ramil,
>
> > It looks great! But i have some other stupid question: How can I
> > override it? I have to put a TActionList in the form? From where
you
> > take the property Dataset from, I mean, (DataSet as TIB_Query),
where
> > is "Dataset"?
>
> > Thank you for the answer!
>
> > []s, Marco André
>
> > --- In IBObjects@yahoogroups.com, Ramil <khabibr@m...> wrote:
> >> Override the standard IB Update action IB_ActionDelete with some
> > like
> >> that:
> >>
> >> procedure TCommonDataSetForm.IB_ActionDelete1Execute(Sender:
> > TObject);
> >> var
> >> i, SelCount: Integer;
> >> TempStrings, SelBookMarks: TStringList;
> >> begin
> >> SelBookMarks:=TStringList.Create;
> >> TempStrings:=TStringList.Create;
> >> try
> >> (DataSet as TIB_Query).SelectedBookmarks(SelBookMarks);
> >> SelCount:=SelBookMarks.Count;
> >> if SelCount>0 then
> >> begin
> >> TempStrings.Clear;
> >> TempStrings.AddStrings(DataSet.ConfirmDeletePrompt);
> >> DataSet.ConfirmDeletePrompt.Clear;
> >> try
> >> DataSet.ConfirmDeletePrompt.Add(
> >> 'Want delete selected rows ('+
> >> IntToStr(SelCount)+')'#10+'from the table
> >> "'+RefInfoProps.Caption+'"?');
> >> // RefInfoProps.Caption it's my own variable
> >> DataSet.DisableControls;
> >> TIB_Query(DataSet).IB_Transaction.AutoCommit:=False;
> >> try
> >> for i:=0 to Pred(SelCount) do
> >> begin
> >> if i=1 then
> >> DataSet.ConfirmDeletePrompt.Clear;
> >> DataSet.Bookmark:=SelBookMarks[i];
> >> DataSet.Delete;
> >> end;
> >> (DataSet as TIB_Query).SelectAll(False);
> >> finally
> >> DataSet.EnableControls;
> >> TIB_Query(DataSet).IB_Transaction.AutoCommit:=True;
> >> TIB_Query(DataSet).IB_Transaction.CommitRetaining;
> >> end;
> >> finally
> >> DataSet.ConfirmDeletePrompt.AddStrings(TempStrings);
> >> end;
> >> end else IB_ActionDelete1.ExecuteTarget(Sender);
> >> finally
> >> TempStrings.Free;
> >> SelBookMarks.Free;
> >> end;
> >> end;
> >>
> >> > Hi All,
> >>
> >> > How can I delete multiple selected rows in a TIB_Grid?
> >>
> >> > Thank you!
> >>
> >> > [Como posso deletar várias linhas selecionadas em um
TIB_Grid
> > ?]
> >>
> >> > []s, Marco André