This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Show control inline in PC/Tablet
#1
Hi,
I have an object that is a 255 byte string and I would display it in line in the visualization. If I check Show control it returns an error.
I don't want that when the user have to write, he must click on the object that open the popup where to write.
Have you any idea how to do that?

Thanks!
Reply
#2
Please someone have any idea how to do that? Huh

Because the popup is horrible, and the client don't like it Confused
Reply
#3
Hi,

What error do you get when enable show control?

BR,

Erwin
Reply
#4
This is the error:

Cannot enable Show control for this object

Possible reasons:
Read-only is enabled
Send fixed value is not empty
Widget is selected
Object datatype is either Time, Date or Color
Control type is set to Custom value select

My object is a 255 byte string, I attach the property:

Attached Files Thumbnail(s)
   
Reply
#5
Try this script, it will enable show control for all elements mapped to group address 1/1/14. No guarantees that it will work though Smile
Code:
addr = '1/1/14'

require('json')
object = knxlib.encodega(addr)
items = db:getall('SELECT id, params FROM visobjects WHERE object=?', object)
for _, item in ipairs(items) do
  params = json.pdecode(item.params)
  if type(params) == 'table' then
    params.showcontrol = 1
    params = json.encode(params)
    db:update('visobjects', { params = params }, { id = item.id })
  end
end
Reply
#6
Thanks admin, but where I have to put it?
Reply
#7
Rut it as a script once
Reply
#8
I tryed to put it in the init script but it didn't work, then I tryed to put it in the Javascript code but it didn't work.

Sorry I forgot to restart the HomeLYnk after put the code in the init script, now it work! Thank you!!! Big Grin
Reply
#9
Create either an event or a resident script, run it and then disable it.
Reply
#10
Thank you very much! Big Grin
Now I have only a problem, how can I change the width of this object, because when I change it via CSS it is overwritten by:
Code:
elemento {
   width: 225px;
}

that I don't be able to change it..

SOLVED: I put this code into javascript:
Code:
$(".Email > div > div > input").attr("style", "width: 700px;");

Big Grin
Reply
#11
you can add !important to CSS rules you want to over-ride.
Code:
.customcls {
    width: 225px !important;
}
Reply
#12
Faster way, thanks! Smile
Reply
#13
I have another problem: when I change the string inside the input box, but don't press enter or the button, the value displayed don't return to the value of the object until I refresh the page, neither if I change page.
Do you have any advice? Smile
Reply
#14
This is why it's not possible to enable show control for text input by default Smile
Reply
#15
Damn Dodgy
Ok, then how can i set the text of the input box? because I tryed this code:
Code:
$(".Email > div > div > input").attr("value", "EXAMPLE");
but the text does't change.
Reply
#16
Hi,

I would create a html with input fields and use javascript to set values to LM and embed it with a iframe into the visu.

BR,

Erwin
Reply
#17
Erwin can you make an example? Because I don't know how to do that. Big Grin
Reply
#18
Use .val("new value") instead of .attr(...)
Reply
#19
(27.01.2017, 15:33)Mirco Wrote: Erwin can you make an example? Because I don't know how to do that. Big Grin

Hi Mirco,

You can create a HTML file like this and put it in a iframe with this URL "/user/input.html", run this LUA code once to create the file:

Code:
-- use this path in your iframe: /user/input.html

dst = '/www/user/input.html'
io.writefile(dst, [[
<!DOCTYPE html">
<head>
 <script type="text/javascript" src="/scada/vis/jquery.js.gz"></script>
 <style type="text/css">
            body {
                background-color: transparent;
            }
         .stringinput{
             width: 240px;
            }
       .savebtn{
             width: 120px;
            }
 </style>
</head>
<body>
 <table width="100" border="0">
   <tr>
 <input id="value1" class="stringinput" type="text" maxlength="255" />
   </tr>
   <tr>
       <input id="btnsave1" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
 <table width="100" border="0">
   <tr>
         <input id="value2" class="stringinput" type="text" maxlength="255" />
   </tr>
    <tr>
 <input id="btnsave2" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
<script>
var p = window.parent;
var obj1dpt;
var obj2dpt;
if (p && p.objectStore){  
 addr1 = p.Scada.encodeGroupAddress('1/2/34');    
 p.objectStore.addListener(addr1, function(obj, type) {
   $("#value1").val(obj.value);
   obj1dpt = obj.rawdatatype;
 });

 addr2 = p.Scada.encodeGroupAddress('1/2/35');    
 p.objectStore.addListener(addr2, function(obj, type) {
   $("#value2").val(obj.value);
   obj2dpt = obj.rawdatatype;
 });

 $("#btnsave1").on("vclick",function(){
   var value1 = $('#value1').val();
   p.setObjectValue({ address: ('1/2/34') , rawdatatype: obj1dpt }, value1, 'text');
 });

 $("#btnsave2").on("vclick",function(){
   var value2 = $('#value2').val();
   p.setObjectValue({ address: ('1/2/35') , rawdatatype: obj2dpt }, value2, 'text');
 });
};
</script>
</body>
</html>
]])
script.disable(_SCRIPTNAME)

BR,

Erwin
Reply
#20
(27.01.2017, 17:14)admin Wrote: Use .val("new value") instead of .attr(...)

Thanks you admin! Now it works!   Smile

This is the code I used:
Code:
var visible = false;
 
 setInterval(function() {
   var state = $('#widget-7').is(':visible');
   if (state != visible) {
     visible = state;
     if (state == false) {
       var tmp = objectStore.objects[Scada.encodeGroupAddress('15/7/215')].value;
       //console.log(tmp);
       $(".Email > div > div > input").val(tmp);
     }
   }
 }, 1000);

When the "widget-7" that contains the text input is closed the text inside the input box is reset!




(28.01.2017, 12:43)Erwin van der Zwart Wrote: Hi Mirco,

You can create a HTML file like this and put it in a iframe with this URL "/user/input.html", run this LUA code once to create the file:

Code:
-- use this path in your iframe: /user/input.html

dst = '/www/user/input.html'
io.writefile(dst, [[
<!DOCTYPE html">
<head>
 <script type="text/javascript" src="/scada/vis/jquery.js.gz"></script>
 <style type="text/css">
            body {
                background-color: transparent;
            }
         .stringinput{
             width: 240px;
            }
       .savebtn{
             width: 120px;
            }
 </style>
</head>
<body>
 <table width="100" border="0">
   <tr>
 <input id="value1" class="stringinput" type="text" maxlength="255" />
   </tr>
   <tr>
       <input id="btnsave1" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
 <table width="100" border="0">
   <tr>
         <input id="value2" class="stringinput" type="text" maxlength="255" />
   </tr>
    <tr>
 <input id="btnsave2" class="savebtn" type="button"value="Save" />
   </tr>
 </table>
<script>
var p = window.parent;
var obj1dpt;
var obj2dpt;
if (p && p.objectStore){  
 addr1 = p.Scada.encodeGroupAddress('1/2/34');    
 p.objectStore.addListener(addr1, function(obj, type) {
   $("#value1").val(obj.value);
   obj1dpt = obj.rawdatatype;
 });

 addr2 = p.Scada.encodeGroupAddress('1/2/35');    
 p.objectStore.addListener(addr2, function(obj, type) {
   $("#value2").val(obj.value);
   obj2dpt = obj.rawdatatype;
 });

 $("#btnsave1").on("vclick",function(){
   var value1 = $('#value1').val();
   p.setObjectValue({ address: ('1/2/34') , rawdatatype: obj1dpt }, value1, 'text');
 });

 $("#btnsave2").on("vclick",function(){
   var value2 = $('#value2').val();
   p.setObjectValue({ address: ('1/2/35') , rawdatatype: obj2dpt }, value2, 'text');
 });
};
</script>
</body>
</html>
]])
script.disable(_SCRIPTNAME)

BR,

Erwin

Thank you Erwin! It works really well! Smile

Now that I understand how to use iframe, we can do almost what we want! Smile
Reply


Forum Jump: