I have a tag with data-bind = "value: contents" for an input tag in KnockOutJS
<input type="text" class="form-control" data-bind="value: contents" />
It displays in following format {"key1":"value1","key2":"value2"}
I'm building a table with name and value then split those keys and values separately and display in TDs
<td>
<strong>
<span id="textKey" data-bind="text: displayKey" />
</strong>
</td>
<td>
<input id="textValue" type="text" data-bind="value: displayValue" />
</td>
Could you help me some ideas of how I can split those keys and values into Dictionary<> and into columns and rows in my case?
Thank you
If you want to use Knockout to populate a HTML table, you can use an
observableArray
with aforeach
data binding. See here for a working JSFiddle, which uses the below code:View Model:
HTML:
If you do not have control over the structure of
contents
, you can use the conversion to array created in your previous thread like this:Html
ViewModel
jsFiddle