bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Supply initial data with the page

Open maxsupermanhd opened this issue 2 years ago • 4 comments

Description

I have a server that can supply initial table data within first request but I don't understand what's the right approach to inject it into the table itself. TLDR I want to avoid separate request for table data and supply first page (initial state) within actual page request.

My first idea was to somehow intercept the first request and just swap in the data without actually performing the request but I don't understand how to actually make it.

Example(s)

https://wz2100-autohost.net/games

Sources: https://github.com/Warzone2100/wz2100-autohost.net/blob/master/layouts/games.gohtml#L32

maxsupermanhd avatar Jul 18 '23 23:07 maxsupermanhd

Maybe the pipeline extension can help you.

wenzhixin avatar Jul 19 '23 03:07 wenzhixin

Yes, looks like a very close thing but still I don't see a way to provide initial data when building a table.

maxsupermanhd avatar Jul 19 '23 13:07 maxsupermanhd

You can also check out this extension: https://bootstrap-table.com/docs/extensions/defer-url/

Example: https://examples.bootstrap-table.com/#extensions/defer-url.html Source: https://examples.bootstrap-table.com/#extensions/defer-url.html#view-source

wenzhixin avatar Jul 19 '23 15:07 wenzhixin

Wow, yes, that's almost exactly what I need, but could I supply JSON or JS variable? I don't enjoy writing a template that generates HTML rows server-side if bootstrap-table already does it why should I implement it twice...

maxsupermanhd avatar Jul 19 '23 18:07 maxsupermanhd

I don't know why the second request should hurt that much, it's done in some ms. But it really want to skip that request you could use the defer-url extension to skip the request and then use the data option to load the data on the initial page load using JSON or a JS variable.

UtechtDustin avatar May 26 '24 19:05 UtechtDustin

We will close this issue, as we got no response from you within the last month. Please let us know if you need further support.

UtechtDustin avatar Jun 24 '24 22:06 UtechtDustin