Jump to content

UniDBGrid.SelectedRows.Clear property


mierlp

Recommended Posts

is there a way to clear all the selected rows in a dbgrid.

 

Hi,

 

For now, you can use like this:

procedure TMainForm.btnClear(Sender: TObject);
begin
  UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll()');
end;

Best regards.

Link to comment
Share on other sites

It works ... But "deselectAll" only works when thrown at another event.
 

///////////////////////////////
// It work
procedure TMainForm.UniFormActivate(Sender: TObject);
begin
  UniDBGrid1.DataSource.DataSet.Close;
  UniDBGrid1.DataSource.DataSet.Open;
end;

procedure TMainForm.btn1Click(Sender: TObject);
begin
  UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll()');
end;
///////////////////////////////
///////////////////////////////
// It doesn't work
procedure TMainForm.UniFormActivate(Sender: TObject);
begin
  UniDBGrid1.DataSource.DataSet.Close;
  UniDBGrid1.DataSource.DataSet.Open;

  // It doesn't work
  UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll()');
end;
///////////////////////////////

 

Link to comment
Share on other sites

 

It works ... But "deselectAll" only works when thrown at another event.

///////////////////////////////
// It doesn't work
procedure TMainForm.UniFormActivate(Sender: TObject);
begin
  UniDBGrid1.DataSource.DataSet.Close;
  UniDBGrid1.DataSource.DataSet.Open;

  // It doesn't work
  UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll()');
end;
///////////////////////////////

 

Hi,

 

Try to use UniDBGrid1->OnAfterLoad event:

procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniDBGrid);
var
  DBGridJSName: string;
begin
  DBGridJSName := UniDBGrid1.JSName;
  UniSession.AddJS('setTimeout(function(){'+ DBGridJSName +'.getSelectionModel().deselectAll()}, 50)');
end;

Best regards.

  • Like 1
Link to comment
Share on other sites

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...