how to hide table row dynamically if any of the td value is empty

382 views
Skip to first unread message

Srikanth Ramaswamy

unread,
Sep 24, 2015, 2:43:56 AM9/24/15
to KnockoutJS
Hi Team,

I am very new to knockout js. Could you please suggest me how can I hide a table row dynamically if any of the td value is empty in that row. 

Thanks nd Regards,
Srikanth G.

Gunnar Liljas

unread,
Sep 24, 2015, 9:25:32 AM9/24/15
to knock...@googlegroups.com
Show us the "td"

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

marks_01

unread,
Sep 24, 2015, 11:40:43 PM9/24/15
to KnockoutJS
try something like this (pseudo code):

<table>
    <!-- ko foreach: MyRowArray -->
        <!-- ko if: MyRow.AllMyCellsHaveValues() -->
            <tr>
                  <td data-bind="text:MyCellProperty1"></td>
                  <td data-bind="text:MyCellProperty2"></td>
                  <td data-bind="text:MyCellProperty3"></td>
                  <td data-bind="text:MyCellProperty4"></td>
            </tr>
        <!-- /ko -->
    <!-- /ko -->
</table>
The above repeats TRs for each item in an array, then uses an IF Binding to check a custom function called AllMyCellsHaveValues().    If the custom function returns false, the that TR won't be rendered.   You'll need to add that custom function to your array item object definition.   I hope that makes sense.


Reply all
Reply to author
Forward
0 new messages