Observable properties in an observableArray

23 wyświetlenia
Przejdź do pierwszej nieodczytanej wiadomości

Scott

nieprzeczytany,
16 paź 2010, 19:17:2016.10.2010
do KnockoutJS
On the wiki it mentions that this is possible but I can't wrap my head
around how to do it. I have an editable grid and each object has an
Active bool property, when removing an item from the grid I want to
change this flag to false instead of completely removing it from the
array. I am able to update the value fine but when I do so the row
doesn't disappear from my grid.

Example of how my template is set up:
<tr data-bind="visible:Active">
<td>...</td>
<td>...</td>
<td><input type="checkbox" data-bind="checked:Active"/>
</tr>

fla...@gmail.com

nieprzeczytany,
17 paź 2010, 05:09:0617.10.2010
do KnockoutJS
Hi Scott

It's certainly possible to do this. I'm not sure why your example code
didn't work - did you forget to make Active an observable property? If
it isn't observable, the UI won't be able to respond to changes on it.
But if it is observable, everything should work as you expect.

To help clarify how this works, I put together a little example for
you at http://pastie.org/1227240. This example has a grid where each
row has an "active" checkbox, as you described. Unchecking it causes
the row to become invisible, without removing the underlying data.

Hope this helps
Steve
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0