Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
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!
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
Please someone have any idea how to do that?
Because the popup is horrible, and the client don't like it
Posts: 1794
Threads: 6
Joined: Jul 2015
Reputation:
120
Hi,
What error do you get when enable show control?
BR,
Erwin
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
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)
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
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
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
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
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
27.01.2017, 08:04
(This post was last modified: 27.01.2017, 08:06 by Mirco .)
Thanks admin, but where I have to put it?
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
27.01.2017, 08:09
(This post was last modified: 27.01.2017, 08:11 by Mirco .)
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!!!
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
Create either an event or a resident script, run it and then disable it.
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
27.01.2017, 08:22
(This post was last modified: 27.01.2017, 08:27 by Mirco .)
Thank you very much!
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:
1 2 3
elemento {
width :
225px ;
}
that I don't be able to change it..
SOLVED: I put this code into javascript:
Code:
1
$(
".Email > div > div > input" ).
attr (
"style" ,
"width: 700px;" );
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
you can add !important to CSS rules you want to over-ride.
Code:
1 2 3
.
customcls {
width :
225px !
important ;
}
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
27.01.2017, 08:48
(This post was last modified: 27.01.2017, 10:04 by Mirco .)
Faster way, thanks!
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
27.01.2017, 10:11
(This post was last modified: 27.01.2017, 10:17 by Mirco .)
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?
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
This is why it's not possible to enable show control for text input by default
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
Damn
Ok, then how can i set the text of the input box? because I tryed this code:
Code:
1
$(
".Email > div > div > input" ).
attr (
"value" ,
"EXAMPLE" );
but the text does't change.
Posts: 1794
Threads: 6
Joined: Jul 2015
Reputation:
120
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
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
Erwin can you make an example? Because I don't know how to do that.
Posts: 8095
Threads: 43
Joined: Jun 2015
Reputation:
471
Use .val("new value") instead of .attr(...)
Posts: 1794
Threads: 6
Joined: Jul 2015
Reputation:
120
28.01.2017, 12:43
(This post was last modified: 28.01.2017, 18:53 by Erwin van der Zwart .)
(27.01.2017, 15:33) Mirco Wrote: Erwin can you make an example? Because I don't know how to do that.
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
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
Posts: 148
Threads: 38
Joined: Sep 2016
Reputation:
1
30.01.2017, 06:53
(This post was last modified: 30.01.2017, 07:07 by Mirco .)
(27.01.2017, 17:14) admin Wrote: Use .val("new value") instead of .attr(...)
Thanks you admin! Now it works!
This is the code I used:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
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!
Now that I understand how to use iframe, we can do almost what we want!