Subject | Re: [IBO] IB_Grid - multiple deletion |
---|---|
Author | Ramil |
Post date | 2005-04-11T04:38:48Z |
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;
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é