Jump to content


Photo

change background tunimdbnumberedi leaving the field

change background tunimdbnumberedi field

  • Please log in to reply
6 replies to this topic

#1 zanona

zanona

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 68 posts

Posted 29 August 2017 - 05:04 PM

How do I change the background color of tunimdbnumberedit when leaving the field?

 

Thanks

 

Zanona


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3430 posts

Posted 29 August 2017 - 07:04 PM

Hi,

 

If I understand you correctly, one of the possible solution to use CSS.

 

For example:

 

1. UniServerModule -> CustomCSS:

.myEl {
    background-color: green;
}

.myEl:focus {
    background-color: white;
}

2. UnimDBNumberEdit -> ClientEvents -> .....

function beforeInit(sender, config)
{
    config.inputCls="myEl";
}

Best regards,


  • 0

#3 zanona

zanona

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 68 posts

Posted 29 August 2017 - 08:29 PM

What if I want to make an example condition!
 
  X <0
Print network
Else
Print blue

  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3430 posts

Posted 29 August 2017 - 08:57 PM

Please give us part of your code here
  • 0

#5 zanona

zanona

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 68 posts

Posted 29 August 2017 - 08:59 PM

I was trying like this, OnChange!

procedure TMainmForm.setColorNeg(vpComp: TUNIMDBNUMBEREDIT);
  var
    vrsStr, vrsStrBak : string;
begin
  vrsStr := 'function beforeInit(sender, config)';
  vrsStr := vrsStr + '{';
  vrsStr := vrsStr + ' config.maxLength=10;';
  vrsStr := vrsStr + ' config.clearIcon=false;';
  vrsStr := vrsStr + ' config.inputCls="myEl";';
  vrsStr := vrsStr + '}';
 
  vrsStrBak := 'function beforeInit(sender, config)';
  vrsStrBak := vrsStrBak + '{';
  vrsStrBak := vrsStrBak + ' config.maxLength=10;';
  vrsStrBak := vrsStrBak + ' config.clearIcon=false;';
  vrsStrBak := vrsStrBak + ' config.inputCls="myEl2";';
  vrsStrBak := vrsStrBak + '}';
 
  vpComp.ClientEvents.UniEvents.Clear;
  if vpComp.Value<0 then begin
    vpComp.ClientEvents.UniEvents.Add(vrsStr);
  end else begin
    vpComp.ClientEvents.UniEvents.Add(vrsStrBak);
  end;
end;

  • 0

#6 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3430 posts

Posted 30 August 2017 - 04:45 AM

Hi,

 

You can try this JS code:

 

UnimDBNumberEdit1 -> ClientEvents -> ExtEvents -> function change:

function change(sender, newValue, oldValue, eOpts)
{
    var me=sender.element.down('input');
    if (newValue < 0) {
        me.removeCls('myEl2');
        me.addCls('myEl1');
    }
    else {
        me.removeCls('myEl1');
        me.addCls('myEl2');
    }
}

Best regards,


  • 0

#7 zanona

zanona

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 68 posts

Posted 30 August 2017 - 08:44 PM

Worked perfectly in the desktop browser but if you squeeze in a cell phone does not change the color!


  • 0





Also tagged with one or more of these keywords: change, background, tunimdbnumberedi, field

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users