Jump to content

How to update CustomCSS


Luciano França

Recommended Posts

I have several settings that I save in my database such as font sizes, colors, etc.
How could I give an update on
"CustomCSS" because I realize that it is only loaded when creating the "TUniServerModule"

Unit ServerModule;

public
  { Public declarations }
  Procedure UpdateCSS;
 End;

Procedure TUniServerModule.UpdateCSS;
Begin
 With Self.customCSS Do Begin
  Add('.x-myfield-focus {  ');
  Add('   border-color: #7eadd9;  ');
  Add('  background-color: #FFFFE1;  ');
  Add('  color: #FF0000;  ');
  Add('  background-image: none;  ');
  Add(' } ');
 End;
End;

//============================================================================================================

Unit Main;
procedure TMainForm.UniFormCreate(Sender: TObject);
begin
 UniServerModule.UpdateCSS;

 UniEdit2.JSInterface.JSConfig('focusCls', ['myfield-focus']);
 UniComboBox1.JSInterface.JSConfig('focusCls', ['myfield-focus']);
end;

 

 

Link to comment
Share on other sites

6 hours ago, Sherzod said:

Hello,

You can use 

Ext.util.CSS.updateRule

Like in this post for example:

 

 

 

I don't understand how this can help me.

see I have appearance settings that I save in the database and I need to pass these settings to CustomCSS

Can you change this attached example ?
 

 

 

 

Modifed CustomCSS.7z

Link to comment
Share on other sites

Well, I believe you can use variables in CSS, and when logging into the system, set the value for these variables, or use the suggested solution

ex: UniSession.AddJS('Ext.util.CSS.updateRule(''.x-btn-default-small'', ''background-color'', ''#162d3f'')');

 

Link to comment
Share on other sites

On 4/18/2024 at 5:11 PM, Luciano França said:

I have several settings that I save in my database such as font sizes, colors, etc.
How could I give an update on
"CustomCSS" because I realize that it is only loaded when creating the "TUniServerModule"

Unit ServerModule;

public
  { Public declarations }
  Procedure UpdateCSS;
 End;

Procedure TUniServerModule.UpdateCSS;
Begin
 With Self.customCSS Do Begin
  Add('.x-myfield-focus {  ');
  Add('   border-color: #7eadd9;  ');
  Add('  background-color: #FFFFE1;  ');
  Add('  color: #FF0000;  ');
  Add('  background-image: none;  ');
  Add(' } ');
 End;
End;

//============================================================================================================

Unit Main;
procedure TMainForm.UniFormCreate(Sender: TObject);
begin
 UniServerModule.UpdateCSS;

 UniEdit2.JSInterface.JSConfig('focusCls', ['myfield-focus']);
 UniComboBox1.JSInterface.JSConfig('focusCls', ['myfield-focus']);
end;

 

 

UniSession.AddJS('Ext.util.CSS.updateRule(''.x-myfield-focus'', ''background-color'', ''#162d3f'')');

 

Link to comment
Share on other sites

6 hours ago, picyka said:

Well, I believe you can use variables in CSS, and when logging into the system, set the value for these variables, or use the suggested solution

ex: UniSession.AddJS('Ext.util.CSS.updateRule(''.x-btn-default-small'', ''background-color'', ''#162d3f'')');

 

How could I put lines in this updateRule logic ?

Procedure TMainForm.UniFormCreate(Sender: TObject);
Begin
 UniSession.AddJS('Ext.util.CSS.updateRule(''.x-myfield-focus'', ''background-color'', ''#ffcccc'')');

 // As ?  Add('background-image: none;  ');

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