stevenrskelton / sortable-table

Polymer Web Component that generates a sortable <table> from inlined or AJAX JSON, JSON5, and arrays.
https://stevenrskelton.github.io/sortable-table/
MIT License
196 stars 37 forks source link

<indexeddb-fruit role="datasource" #24

Closed gertcuykens closed 9 years ago

gertcuykens commented 9 years ago

This seem to be broken <indexeddb-fruit role="datasource"> </indexeddb-fruit> I need to add something in columns before it start working like columns='[{"name":"name", cellTemplate: "fruitsTemplate"}]' note that it also ignores the content of column, it always shows all columns or none.

                 <sortable-table class="extjs4"
                footerTemplate="defaultPager"
                pageSize="10"
                loading="{{loading}}" >

                        <template id="fruitsTemplate">
                            <td><a href="#{{value}}">{{value}}</a></td>
                        </template>

                        <indexeddb-fruit
                            role="datasource"
                            columns='[
                                {"name":"name", cellTemplate: "fruitsTemplate"},
                            ]'
                        ></indexeddb-fruit>

                    </sortable-table>
stevenrskelton commented 9 years ago

A couple things need to be exact for this to work:

1: columns needs to be defined within the sortable-table attributes (and not within the indexeddb-fruit attributes).

The indexeddb-fruit is blindly returning each row from the indexeddb store to the grid, so the grid will display all of the rows if it doesn't have a columns defined.

I'd create generic logic to do this properly, but the entire indexeddb datasource is necessarily very specific, since something needs to load all the data into it and create the proper indexes. Maybe in the future, but to be honest I don't have a need for it so it's a rather low priority :grimacing:

2: When loading attributes, only valid JSON can be used, JSON5 doesn't work. So in your code "cellTemplate" needs to be quoted, otherwise it won't parse as an Array.