mardi 13 février 2018

KnockoutJS Data-bind If : Observable has precision of X

Is there a way to data-bind an observable only if it has a precision of say 1, 2 or 3? Below is my VM:

function FFS_ViewModel() {
    var self = this;
    .....
    self.SortOrder = ko.observable();
    self.Description = ko.observable();
    self.records = ko.observableArray([]);
})

Here is the View:

<table class='TFtable'>
   <thead>
       <tr>
         <th>Sort Order</th>
       </tr>
   </thead>
   <tbody data-bind="foreach: records">
       <tr id="mainFactors">
            <td data-bind="if: SortOrder, precision: 2">
                        <!--<td data-bind="text: SortOrder">-->
                    </td>
                        <td data-bind="text: Description"></td>
                    </tr>
                </tbody>
            </table>

Is this something you can set on the view side or does it need to be a pure computed function on the view model side?

Aucun commentaire:

Enregistrer un commentaire