zanona Posted August 29, 2017 Share Posted August 29, 2017 How do I change the background color of tunimdbnumberedit when leaving the field? Thanks Zanona Link to comment Share on other sites More sharing options...
Sherzod Posted August 29, 2017 Share Posted August 29, 2017 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, Link to comment Share on other sites More sharing options...
zanona Posted August 29, 2017 Author Share Posted August 29, 2017 What if I want to make an example condition! X <0 Print network Else Print blue Link to comment Share on other sites More sharing options...
Sherzod Posted August 29, 2017 Share Posted August 29, 2017 Please give us part of your code here Link to comment Share on other sites More sharing options...
zanona Posted August 29, 2017 Author Share Posted August 29, 2017 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; Link to comment Share on other sites More sharing options...
Sherzod Posted August 30, 2017 Share Posted August 30, 2017 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, Link to comment Share on other sites More sharing options...
zanona Posted August 30, 2017 Author Share Posted August 30, 2017 Worked perfectly in the desktop browser but if you squeeze in a cell phone does not change the color! Link to comment Share on other sites More sharing options...
Recommended Posts