Jump to content

Refresh ReadOnly dataset using UniDBNavigator


Hassan

Recommended Posts

Hi,

 

UniDBNavigator refresh button is disabled when DataSet is read-only.

I have read-only dataset. For different reasons user need to click on REFRESH button of UNIDBNAVIGATOR which is referencing to this read-only dataset.

 

Is there a way to make Refresh button active for read-only data-set?

 

Thanks.

Link to comment
Share on other sites

Hi,

 

Can you try this approach ?!:

 

1.

uses ... DBCtrls;

2.

type
  TExUniDBNavigator = class(TUniDBNavigator)

  end;

3.  UniDBGrid -> OnAfterLoad:

procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniDBGrid);
begin
  TExUniDBNavigator(UniDBNavigator1).Buttons[nbRefresh].Enabled := True;
end;

Best regards,

  • Upvote 1
Link to comment
Share on other sites

That works. But I will need to add it to all grids with readonly dataset...

procedure TUniDBNavigator.EditingChanged;
var
  CanModify: Boolean;
begin
  if IsDestroying then Exit;

  CanModify := Enabled and FDataLink.Active and FDataLink.DataSet.CanModify;
  Buttons[nbInsert].Enabled := CanModify;
  Buttons[nbEdit].Enabled := CanModify and not FDataLink.Editing;
  Buttons[nbPost].Enabled := CanModify and FDataLink.Editing;
  Buttons[nbCancel].Enabled := CanModify and FDataLink.Editing;
  Buttons[nbRefresh].Enabled := CanModify;
end;

I see in UniDBNavigator.pas , it is enabled based on 'Enabled and FDataLink.Active and FDataLink.DataSet.CanModify;' (above code).

To me it should be as follows:

procedure TUniDBNavigator.EditingChanged;
var
  CanModify: Boolean;
begin
  if IsDestroying then Exit;

  CanModify := Enabled and FDataLink.Active and FDataLink.DataSet.CanModify;
  Buttons[nbInsert].Enabled := CanModify;
  Buttons[nbEdit].Enabled := CanModify and not FDataLink.Editing;
  Buttons[nbPost].Enabled := CanModify and FDataLink.Editing;
  Buttons[nbCancel].Enabled := CanModify and FDataLink.Editing;
  Buttons[nbRefresh].Enabled := Enabled and FDataLink.Active;
end;

Is this change can be applied?

Thanks.

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