Jstree checkbox disable/Enabled

1,114 views
Skip to first unread message

Tommaso Pinto

unread,
Nov 27, 2014, 5:29:03 AM11/27/14
to jst...@googlegroups.com
Hi all, I'm try to  do the same effect like this:


but with Jstree V3.
 

this is my json data:

[
  {
    "text": "Permessi",
    "parent": "#",
    "li_attr": {
      "id": 0
    },
    "id": 0
  },
  {
    "text": "Giovanna Codelupi",
    "parent": 0,
    "li_attr": {
      "id": "category_Giovanna Codelupi"
    },
    "id": "333"
  },
  {
    "text": "Visibilit\u00e0",
    "state": {
      "disabled": true,
      "checked": false
    },
    "id": 1,
    "parent": "333",
    "li_attr": {
      "id": "permission_1"
    }
  },
  {
    "text": "Accesso HB",
    "state": {
      "disabled": true,
      "checked": false
    },
    "id": 4,
    "parent": 1,
    "li_attr": {
      "id": "permission_4"
    }
  },
  {
    "text": "Test",
    "state": {
      "disabled": false,
      "checked": false
    },
    "id": 5,
    "parent": 2,
    "li_attr": {
      "id": "permission_5"
    }
  },
  {
    "text": "Men\u00f9 HB dispositivo",
    "state": {
      "disabled": true,
      "checked": false
    },
    "id": 3,
    "parent": "333",
    "li_attr": {
      "id": "permission_3"
    }
  },
  {
    "text": "Uscita",
    "state": {
      "disabled": false,
      "checked": false
    },
    "id": 2,
    "parent": "333",
    "li_attr": {
      "id": "permission_2"
    }
  }
]

Html:

$(function () {
               $("#plugins_test").jstree({
                    checkbox : {
                         'three_state' : true
                    },
                    "plugins" : [  "checkbox","types"],

            'core': {
                'data': {
                    'url': "{% url json%}",
                    'type': 'Get',
                    'dataType': 'JSON',
                }

            }
        })
   })


So when I check a parent of disabled checkbox it cheched too, and of course the function get_selected return me disable checkbox.

How can I resolve this??

I'm try with types too but it's not work.

Regard 
tommy

Ivan Bozhanov

unread,
Nov 27, 2014, 6:32:20 AM11/27/14
to jst...@googlegroups.com
Take a look at the checkbox plugin config options - especially the cascade option, as for get_selected, you may also want to have a look at get_top_selected and get_bottom_selected.
If you want to filter out the selection in some way, you may want to try out .get_selected(true) and then interate through the array and remove the nodes with state.disabled === true

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages