ratiw / vue-table

data table simplify! -- vuetable is a Vue.js component that will automatically request (JSON) data from the server and display them nicely in html table with swappable/extensible pagination component.
MIT License
1.83k stars 303 forks source link

Default focused position #131

Closed Jordy-A closed 7 years ago

Jordy-A commented 7 years ago

By default, the users are ordered by id. Is there an option to display the table with a certain user selected by default?

For example, when a user with ID #49 is logged in. When he loads the page, the default page is 5, because it is his 'ranking position' in the table.

Something like:

<vuetable
  api-url="/api/users"
  :focus-on-user="{id:49}"
></vuetable>
ratiw commented 7 years ago

@Jordy-A No, there is no option like that. But you should be able to do that yourself in ready function of the main Vue.js instance (because vuetable would have already finished loading the data from the server) By creating a function to loop through vuetable's tableDatafor the given ID, then calculate which page it supposed to be, and then broadcast vuetable's vuetable:goto-page event to set vuetable to that page.