Simple Sample: https://www.dropbox.com/s/oa3ffhhsgnlej5k/UIBinding.zip?dl=0
Basically I want to have the items in my drawer be selectable, so when clicked, change the state... but the items don't seem to update, am I doing this wrong??
6 Answers, 1 is accepted
Yesterday we released a version that addresses the problem. Can you try it out with it?
Regards,
Nick
Telerik
Will do thanks!
Hey, is there no release notes for the version updates anywhere to look at?
Nothing seems to be happening for me...
<
Label
row
=
"0"
col
=
"0"
text
=
""
class
=
"{{ isSelected ? 'drawericon selected materialdesign' : 'drawericon materialdesign' }}"
/>
Doesn't matter how I change the bool, the UI doesn't update
exports.onSelectTopic =
function
(args){
var
stack = args.object;
var
item = stack.bindingContext;
item.isSelected =
true
;
viewModel.topics.getItem(0).isSelected =
true
;
If I remove the css binding and just make it class="drawericon selected materialdesign" I see the fonticons color change, so I know there is a "selected" definition set in the CSS that works.
Also if I edit the code before binding such that isSelected is true for everything the UI also reflects that based on the css set.
In order for the UI to receive notifications about the change in the bound properties, you need to use the set("propertyName", value) and get("propertyName") methods in the observable class.
Hope this helps.
Regards,
Nick
Telerik
So "topics" is an observable array... the items bound in the sidedrawer are items in that array
topics: new observableArray.ObservableArray(),
So I do see that "setItem" is an option, and seems to work, so is that then what I need to do? Loop though the items in the obsArray, find the item I want and replace it, or is there an easier way to know the index of a clicked item though it's binding context or something?
The control placed insidethe SideDrawer's contents will handle the observable array changes only if it supports observable arrays. In any other case you have to manually update it to replicate the changes in the UI. The approach you found is a valid one, so you can use it.
As to the index of the clicked item, again, it depends on what the container for that item is, and if it supports indexation of its children.
Hope this makes sense.
Regards,
Nick
Telerik