Jump to content

TUniCustomDBGrid.MoveToRow(): Unexpected Row number: 0, 3.


erich.wanker

Recommended Posts

3 hours ago, Wilton Ergon said:

em algumas telas de uso intenso, simplesmente abandonei o uso do grid, crio listas em html puro, onde o resultado visual é bem mais bonito, mais rápido, e não dá todos esses problemas, podemos nos contentar com o que ter..

If you can give me an example, I'd appreciate it, when you have the native option to mark the record, that's where the error happens

Link to comment
Share on other sites

4 hours ago, Wilton Ergon said:

in some screens of intense use, I simply abandoned the use of the grid, I create lists in pure html, where the visual result is much prettier, faster, and it doesn't give all these problems, we can make do with what we have..

Hi

Is it possible to share this code?

Regards

Link to comment
Share on other sites

  • 4 weeks later...
  • 6 months later...

Hi,


For me, it happens when I have an event in UniDBGrid and ActionColumn:

1653253924_1sample.thumb.png.c31c0cf84dadd589341fb36857cae1eb.png

And the events execute this code:

1089603643_2sample.png.b5457267aee72e980d9c0c2853aa880f.png


And this happens(it only happens the first time u delete a row):
846078222_3sample.gif.4c4782d1600be3572b83b8bb1ce0cccc.gif

 

but when u remove the OnCellClick event, the bug wont show.

Any idea how to resolve it ?

 

Link to comment
Share on other sites

@Denton

If this suits you, you may need confirmation, which gives you a workaround:

procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin
  MessageDlg('Are you sure..?', mtConfirmation, [mbYes, mbNo],
    procedure (AComponent: TComponent; ARes: Integer)
    begin
      if ARes = mrYes then
        UniMainModule.ClientDataSet1.Delete;
    end
  )
end;

 

Link to comment
Share on other sites

1 hour ago, Denton said:

in my case i dont use delete ActionColumn.. I use add Action Column which when clicked, the data goes to another grid.. so it doesnt need confirmation..

Okay. But it seems to me that the error is related to the deletion of the record!?

Link to comment
Share on other sites

On 10/11/2022 at 1:36 PM, Denton said:

Hi

Here.. if u remove the OnCellClick event the bug wont show...

GridCheckBox.rar 7.64 kB · 4 downloads

I am not sure this is helpful , something (procedure or function) delayed untill OnCellClick. 

So i changed your source code.

 

type

  TMainForm = class(TUniForm)
    UniDBGrid1: TUniDBGrid;
    UniDBNavigator1: TUniDBNavigator;
    DataSource1: TDataSource;
    procedure UniFormCreate(Sender: TObject);
    procedure UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn; ButtonId: Integer);
    procedure UniDBGrid1CellClick(Column: TUniDBGridColumn);
  private
    { Private declarations }
    DeleteJobReady: boolean;
  public
    { Public declarations }
  end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
  uniGUIVars, MainModule, uniGUIApplication, StrUtils;

function MainForm: TMainForm;
begin
  Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniDBGrid1CellClick(Column: TUniDBGridColumn);
begin
  if DeleteJobReady then
  begin
    UniMainModule.ClientDataSet1.Delete;
    DeleteJobReady := false;
  end;

end;

procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn; ButtonId: Integer);
begin
  DeleteJobReady := true;
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer;
begin
  DeleteJobReady := false;
  with UniMainModule.ClientDataSet1 do
  begin
    for I := 1 to 100 do
    begin
      Append;
      FieldByName('EmpNo').AsInteger    := I;
      FieldByName('Lastname').AsString  := Char(65 + Random(28));
      FieldByName('Firstname').AsString := Char(65 + Random(28));

      FieldByName('shift').AsBoolean     := Random(2) = 1;
      FieldByName('BoolInt').AsInteger   := Random(2);
      FieldByName('Boolstring').AsString := IfThen(Random(2) = 0, 'set', 'unset');
      Post;
    end;
    First;
  end;
end;

 

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...