# Disabling items in a listview with a checkbox

**URL:** <https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849>\
**Category:** Help & Support\
**Tags:** script, jscript\
**Created:** [June 12, 2020, 6:14am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849 "2020-06-12T06:14:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve](https://resource.dopus.com/user_avatar/resource.dopus.com/steve/32/34171_2.png) [@Steve](https://resource.dopus.com/u/Steve)\
**Post date:** [June 12, 2020, 6:14am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/1 "2020-06-12T06:14:56Z")

</div>

I am having issues with the new ability to disable items in listviews. The following button/code gives an example of the issue. I create a dialog with an automatic checkbox listview, add three items, one of which is disabled with its checkbox set to 3 - disabled and unchecked.

When you close the dialog it outputs the current status of the .checked state for all items.

The disabled and unchecked item reports the same as the checked items. Am I doing something wrong here please?

[Disable Test.dcf](https://resource.dopus.com/uploads/short-url/93OSv17MLBRaIe1oLYuAo1YGwkr.dcf) (2.8 KB)

````auto
function OnClick(clickData)
{
	var dlg = DOpus.Dlg();
	dlg.title = "Test";
	dlg.template = "dialog1";
	dlg.detach = true;
	dlg.want_close = true;
	dlg.Create();

	dlg.Control("list").columns.AddColumn("Col 1");

	var i = dlg.Control("list").AddItem("Folder 1");
	var i = dlg.Control("list").AddItem("Folder 2");
	dlg.Control("list").GetItemAt(i).disabled = true;
	dlg.Control("list").GetItemAt(i).checked = 3;
	var i = dlg.Control("list").AddItem("Folder 3");

	dlg.Control("list").columns.AutoSize();

	dlg.Show();

	while (true) {
        var msg = dlg.GetMsg();
        if (!msg.result) break;

		if (msg.event == "close") {
			for (i=0; i < dlg.Control("list").count; i ++) {
            	DOpus.Output(dlg.Control("list").GetItemAt(i).checked);
        	}
			dlg.EndDlg();
		}
    }
}```
````

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [June 12, 2020, 7:09am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/2 "2020-06-12T07:09:10Z")

</div>

Looks like a bug with the "checked" property; it's being reported as a bool, not an int, so only reports zero or non-zero. Will fix this in the next update. I don't think this has anything to do with the new disable feature for items though.

---

<div class="post-metadata">

**Author:** ![Steve](https://resource.dopus.com/user_avatar/resource.dopus.com/steve/32/34171_2.png) [@Steve](https://resource.dopus.com/u/Steve)\
**Post date:** [June 12, 2020, 7:10am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/3 "2020-06-12T07:10:23Z")

</div>

Ok thanks @jon.

---

<div class="post-metadata">

**Author:** ![Steve](https://resource.dopus.com/user_avatar/resource.dopus.com/steve/32/34171_2.png) [@Steve](https://resource.dopus.com/u/Steve)\
**Post date:** [June 12, 2020, 10:21am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/4 "2020-06-12T10:21:18Z")

</div>

Further to this, taking checkboxes out of the equation - still results in odd results.

Try this button, [Disable Test.dcf](https://resource.dopus.com/uploads/short-url/uYzn4pxbychY19FNB1Hxd6TxQ0s.dcf) (2.8 KB)

Which uses this code and doesn't correctly report the disabled boolean.

```auto
function OnClick(clickData)
{
	var dlg = DOpus.Dlg();
	dlg.title = "Test";
	dlg.template = "dialog1";
	dlg.detach = true;
	dlg.want_close = true;
	dlg.Create();

	dlg.Control("list").columns.AddColumn("Col 1");

	var i = dlg.Control("list").AddItem("Folder 1");
	var i = dlg.Control("list").AddItem("Folder 2");
	dlg.Control("list").GetItemAt(i).disabled = true;
	//dlg.Control("list").GetItemAt(i).checked = 3;
	var i = dlg.Control("list").AddItem("Folder 3");

	dlg.Control("list").columns.AutoSize();
	DOpus.ClearOutput();
	dlg.Show();

	while (true) {
        var msg = dlg.GetMsg();
        if (!msg.result) break;

		if (msg.event == "close") {
			for (i=0; i < dlg.Control("list").count; i ++) {
            	DOpus.Output(dlg.Control("list").GetItemAt(i).disabled);
        	}
			dlg.EndDlg();
		}
    }
}

```

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [June 22, 2020, 5:24am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/5 "2020-06-22T05:24:53Z")

</div>

That's fixed now in [12.21](https://resource.dopus.com/t/directory-opus-12-21/35919).

---

<div class="post-metadata">

**Author:** ![Steve](https://resource.dopus.com/user_avatar/resource.dopus.com/steve/32/34171_2.png) [@Steve](https://resource.dopus.com/u/Steve)\
**Post date:** [June 22, 2020, 6:01am UTC](https://resource.dopus.com/t/disabling-items-in-a-listview-with-a-checkbox/35849/6 "2020-06-22T06:01:53Z")

</div>

Thanks @Jon

I just noticed too that integer and boolean variables are now reporting themselves as "int" and "bool" instead of "number" and "boolean" which confused me for a bit. 🙂
