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.

To Use Read only just for false condition of status object
#1
Hi,

I have an 1 bit object on visualation. We are sending fixed value as "1". This object also have a status group address. 

We want that, if the status object is 0, command object will act like read only. It will not send any command.

How we can do it ?

Regards,
Reply
#2
(21.03.2024, 18:15)savaskorkmaz Wrote: Hi,

I have an 1 bit object on visualation. We are sending fixed value as "1". This object also have a status group address. 

We want that, if the status object is 0, command object will act like read only. It will not send any command.

How we can do it ?

Regards,

$(function() {
  $('.hidden-by-value').each(function(_, el) {
    var addr = $(el).data('object');
    if (addr) {
      grp.listen(addr, function(obj) {
        var value = obj.value;
        if (value) {
          $(el).addClass('item-read-only').removeClass('hidden-by-value');
        } else {
          $(el).removeClass('item-read-only').addClass('hidden-by-value');
        }
      });
    }
  });
});
Reply
#3
Hi Fahd ,
Nice to hear you again Smile

Is it javascript ?
Reply
#4
(22.03.2024, 11:47)savaskorkmaz Wrote: Hi Fahd ,
Nice to hear you again Smile
Is it javascript ?


Hi Savas,
Yes, just add hidden-by-value to the additional classes for the objects that you want to apply that function to.
Reply
#5
Hı Fahd, it didn't worked.
I think i explained with lack of information. Let me explain with example.
I have one object in visualation with 1/1/1 for command and 1/1/2 for status.
I want that,
when 1/1/2 ( the status ) is false then 1/1/1 will be read only.
When 1/1/2 ( the status ) is true then 1/1/1 will be writable.

Thanks
Reply
#6
Add to Custom JS and use read-only-by-value Additional class.
Code:
$(function() {
  $('.read-only-by-value').each(function(_, el) {
    var addr = $(el).data('status-object');

    if (addr) {
      grp.listen(addr, function(obj) {
        $(el).toggleClass('item-read-only', !obj.value);
      });
    }
  });
});
Reply
#7
Thanks a lot, it worked

(25.03.2024, 11:36)admin Wrote: Add to Custom JS and use read-only-by-value Additional class.
Code:
$(function() {
  $('.read-only-by-value').each(function(_, el) {
    var addr = $(el).data('status-object');

    if (addr) {
      grp.listen(addr, function(obj) {
        $(el).toggleClass('item-read-only', !obj.value);
      });
    }
  });
});
Reply


Forum Jump: