1rosehip / jplist-es6

jPList is a JavaScript library for sorting, pagination and filtering of any HTML structure like DIVs, UL/LI, tables, etc.
https://www.jplist.org/
MIT License
83 stars 38 forks source link

Selected true not working on Sort datetime #52

Open Schouw opened 5 years ago

Schouw commented 5 years ago

When a sort button (i have only tried the dropdown menu version) is set with data-type="datetime" and data-selected="true", this does not select the sort on jp list init.

I have set the data-datetime-format and the sorting workings just as intended if the dropdown menu item is selected by the user. It is simply not selected as the default when the page is first loaded.

` <div class="dropdown mr-3" data-jplist-control="dropdown-sort" data-opened-class="show" data-group="articles" data-name="sort">

      <button
            data-type="panel"
            class="btn btn-primary dropdown-toggle"
            type="button">
                Sort by
       </button>

                        <div
                                data-type="content"
                                class="dropdown-menu"
                                aria-labelledby="dropdownMenuButton">

                            <a class="dropdown-item"
                               href="#"
                               data-path="default">-- No sort --</a>

                            <a class="dropdown-item"
                               href="#"
                               data-path="#article-publication-status"
                               data-order="asc"
                               data-type="datetime"
                               data-selected="true"
                               data-datetime-format="dd/MM - yyyy HH:mm">Created Newest-Oldest</a>

                            <a class="dropdown-item"
                               href="#"
                               data-path="#article-publication-status"
                               data-order="desc"
                               data-type="datetime"
                               data-datetime-format="dd/MM - yyyy HH:mm">Created Oldest-Newest</a>

                        </div>
                    </div>
                    <!-- Sort button -->

`

Test data `

        <tbody>
            <tr data-jplist-item>
                    <td scope="row" id="article-title">dafafd</td>
                    <td id="article-publication-status">UNPUBLICED</td>
                    <td>03/08 - 2019 16:07</td>
                </tr>
               <tr data-jplist-item>
                    <td scope="row" id="article-title">Tester</td>
                    <td id="article-publication-status">DRAFT</td>
                    <td>02/08 - 2019 23:51</td>
                </tr>
        </tbody>
    </table> `
Title Status Created