Jump to content

dbgrid roweditor stopped working


sicoobcooplivre

Recommended Posts

2 minutes ago, sicoobcooplivre said:

So: by default, my forms load like this:

UniDBGrid1.Options := [         dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgConfirmDelete,dgTabs,dgCancelOnExit];

When I click the edit button, I need to change the options like this:

UniDBGrid1.Options := [dgEditing,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgConfirmDelete,dgTabs,dgCancelOnExit];

and I need the roweditor combobox to work, as shown in the image.

I'll try to provide a workaround tomorrow.

Link to comment
Share on other sites

1 hour ago, sicoobcooplivre said:

but since I don't have little knowledge, I couldn't apply the method in my example.
Please, can't you apply it to the example I attached here on the forum to help me?

Can you try?

In your testcase:

1. MainFrom.OnCreate event:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniDBGrid1.CustomAttribs.Values['rdonly'] := 'true'; //<----------
  with PFmtSettings^ do
  begin
    DateSeparator := '/';
    CurrencyFormat := 0;
    CurrencyString := '$';
  end;
end;

2. 

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniButton1.Enabled := False;
  UniButton2.Enabled := True;
  UniButton3.Enabled := True;

  //UniDBGrid1.Options := [dgEditing,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgConfirmDelete,dgTabs,dgCancelOnExit];
  UniDBGrid1.CustomAttribs.Values['rdonly'] := 'false';
end;

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  UniButton1.Enabled := True;
  UniButton2.Enabled := False;
  UniButton3.Enabled := False;

  //UniDBGrid1.Options := [dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgConfirmDelete,dgTabs,dgCancelOnExit];
  UniDBGrid1.CustomAttribs.Values['rdonly'] := 'true';
end;

procedure TMainForm.UniButton3Click(Sender: TObject);
begin
  UniButton1.Enabled := True;
  UniButton2.Enabled := False;
  UniButton3.Enabled := False;

  //UniDBGrid1.Options := [dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgConfirmDelete,dgTabs,dgCancelOnExit];
  UniDBGrid1.CustomAttribs.Values['rdonly'] := 'true';
end;

3. In designTime:

UniDBGrid1.Options = [dgEditing, ...]

4. UniDBGrid1.ClientEvents.ExtEvents ->

function beforeedit(editor, context, eOpts)
{
    return ajaxRequest(this, 'getCheck', [], false).responseText !== 'true';
}

5. UniDBGrid1.OnAjaxEvent:

procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = 'getCheck' then
  begin
    UniSession.SendResponse((Sender as TUniDBGrid).CustomAttribs.Values['rdonly']);
  end;
end;

 

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