pjekel/cbtree

ReadOnly checkbox not updated visually when changed in the store.

Closed this issue · 6 comments

So far using your cbtree has been awesome, but I ran into a little problem with the readonly aspect. I've been doing some logging and it seems that the store readonly value is being updated properly, but it is not shown in the displayed grid.

By the way, we are using a pretty customized store implementation for interfacing with arcgis server. In my logging the readonly is only ever checked the first time you expand the nodes of the tree, after that is never checked again.

Thanks for any help you can provide.

The cbtree does not check the store for updates, instead the store model listens for events from the store. All store related updates are event driven. To dynamically update the cbtree your store MUST emit change, new or remove events.

To have your custom store emit those kind of events you can use the Eventable store wrapper or you can implement your own event emission by including cbtree/Evented.js in your custom store.

You can take a look at the cbtree ObjectStore how the cbtree/Evented.js module is used.

Let me know if that works.

I did actually try the Eventable wrapper before I posted that without any luck.

I did switch my store to mixing in your evented instead of the dojo one and am emitting the change event. this event is firing (I am catching it outside the tree as well to log it), but the readonly is not being updated still.

this.emit("change", { type: "change", detail: { item: object, oldItem: orgObj} });

Thanks for the quick reply!

OK, considering you are using a customized store and I don't know which store you based it on (dojo/store or cbtree/store), please check the following:

  1. On order for the store model to recognize any store to be able to generate events, the store MUST
    have two properties:
    1. an emit() method
    2. eventable = true

As in:

emit: function (...) {
},

eventable: true,

Typically, the Eventable wrapper sets those properties for you.

Also make sure your have the enabledAttr property of the store model set to a valid store property. The default is an empty string.

That was it, was missing the:

eventable: true

Thank you so much for your assistance, scrolled right down to the put method and skipped over that in the objectstore.

Sorry to reopen this, but I have a related question. I got back to working on this this morning and noticed that the parent checkboxes are not being updated when children are clicked, and vice versa. In trouble shooting I removed the eventable: true from my store and now the checkboxes don't work but I'm back to the previous problem.

Just wondering if you have any ideas on what might cause this behavior? I was apparently so excited the readonly was working I didn't realize the vital bit wasn't functioning. Thanks for any help you can give!

It is a little hard for me to 'remotely' diagnose the problem without having see any of your code. Please post a short question @ http://www.thejekels.com/blog/featured/the-new-dijit-checkbox-tree/ so I have your email and we can take this off line. For starters, list all version number of the products your are using such as dojo, cbtree. What kind of store model are you using? etc, etc.