-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Currently, the collection option only knows how to deal with strings, as viewModel[collection] is used to access the desired array. This works fine, except in cases where you need to use Knockout's $data context property as the collection option. While using $data as the collection may sound strange, I have a use case for it (I'm inside a KO with binding, and at that point, $data is my collection).
My proposal to fix this is to make the binding capable of accepting references to the collection itself for the collection option. The diff for my commit is at the bottom - I've done some testing, and things seem to work fine. I'll be testing further tomorrow - just wanted to get the idea out there.
Proposed Example HTML 1 (reference collection by name)
<table class="table-ordered">
<thead>
<tr>
<th data-bind="orderable: { collection: 'Collection', field: 'FieldName' }">Column Header</th>
(rest of table header here)
</tr>
<tbody data-bind="foreach: $data">
(table body context here)
</tbody>
</thead>
</table>Proposed Example HTML 2 (reference collection by object)
<table class="table-ordered">
<thead>
<tr>
<th data-bind="orderable: { collection: Collection, field: 'FieldName' }">Column Header</th>
(rest of table header here)
</tr>
<tbody data-bind="foreach: $data">
(table body context here)
</tbody>
</thead>
</table>Proposed Example HTML 3 (reference collection by $data property
<table class="table-ordered" data-bind="with: Collection">
<thead>
<tr>
<th data-bind="orderable: { collection: $data, field: 'FieldName' }">Column Header</th>
(rest of table header here)
</tr>
<tbody data-bind="foreach: $data">
(table body context here)
</tbody>
</thead>
</table>Proposed Script
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels