I have a list of attributes with different datatype, if the datatype is a check box then i would like the bind the value in string to checkbox. I managed to bind the value from database to UI. But if there is any modification to the value, I could not capture it back from the list. Could anyone advice on this?
Thanks.
UI Code
<tbody data-bind="foreach: data().Attributes">
<tr>
<th data-bind="text: AttributeName"></th>
<td>
<span data-bind="if: AttributeDataType === 'CheckBox'">
<input class="input-sm" type="checkbox" data-bind="value: AttributeValue, checked: $parent.ConvertToBoolean(AttributeValue), visible: $parent.editMode() " />
</span>
<span data-bind="if: AttributeDataType === 'Text'">
<input class="input-sm" type="text" data-bind="value: AttributeValue, visible: $parent.editMode() " style="min-width: 300px;" />
</span>
<span data-bind="if: AttributeDataType === 'DropDown'">
<select class="selectpicker" data-bind="options: $parent.availableTestProgramType, value: AttributeValue, visible: $parent.editMode() "></select>
</span>
</td>
</tr>
</tbody>
Script
public data = ko.observable<any>([]);
public ConvertToBoolean = (x: string) => {
return x == "true" ? true : false; }
Aucun commentaire:
Enregistrer un commentaire