Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing features from a json file for data-side-pagination="server" #2105

Closed
nyarachm opened this issue Mar 23, 2016 · 10 comments
Closed

Accessing features from a json file for data-side-pagination="server" #2105

nyarachm opened this issue Mar 23, 2016 · 10 comments
Labels
export Issues for the export extension.

Comments

@nyarachm
Copy link

Hi,

I am testing out the table features on my localhost and successfully used the search, sort, pagination and export when using data-side-pagination="client" (and configuring the json file as shown in the documentation).

without server-side (works): https://github.com/wenzhixin/bootstrap-table-examples/blob/master/json/data1.json
with server-side (NOT working): https://github.com/wenzhixin/bootstrap-table-examples/blob/master/json/data2.json

When I change to server-side, I successfully get the data to output in the table but all the features do not work (search, sort, pagination and export). Export outputs the entire table.

I have had a look here http://jsfiddle.net/4r6g4cfu/3/light/ and when I replicate this example and use the data-url (http://mikepenz.com/jsfiddle/) provided it works. But my http://localhost/testtable/scripts/json/test.json doesnt.

NOTE: http://localhost/testtable/scripts/json/test.json is identical to http://mikepenz.com/jsfiddle. I copy/pasted

@nyarachm nyarachm changed the title Accessing a json file for data-side-pagination="server" Accessing features from a json file for data-side-pagination="server" Mar 23, 2016
@dabros
Copy link
Contributor

dabros commented Mar 24, 2016

@nyarachm - you do know what "server-side" means?

#1980
#1862

"client-side" means js code doing most the grunt work, "server-side" is where you point to a server side SCRIPT (NOT a raw data file) that handles the param you send along with it and returns prepared results.

There is nothing bootstrap-table has to do with that process, except in the name and values of param sent, and you can even configure those to whatever you want.

Hit F12 and see whats actually being sent and returned in network requests to see what i mean.
http://issues.wenzhixin.net.cn/bootstrap-table/#options/server-side-pagination.html

If still unsure, then through issues and ect for server side code or just google to find similar scripts in whatever language and database/datastore your using then change param to match naming scheme.

@dabros
Copy link
Contributor

dabros commented Mar 24, 2016

@nyarachm - I like that your looking at other issues, but you need to make better use of the search feature here and remember to remove "is:open" filter.

And please dont spam same question in barely related posts when it does fit far better here in its own thread (or in the duplicate thread i linked to above)

Thanks

@nyarachm
Copy link
Author

@dabros Hi, thanks for the quick advice! Sorry about asking all over. I have had a look at #1980 as well as the other links previously and have successfully managed to fix the pagination issue. This is my first time using json as before I used to use ajax.

However this did not fix the search, sort, and export functions. This issue only happens when I get data from server. I am still looking around the 'issues' area (and your links) for a possible solution and will report on my success or failure. Thanks

@nyarachm
Copy link
Author

Positive Update! Massive thanks to @jaydeepgiri in #617. I finally got the sort feature working.

The 5 golden variables (the author of the documentation should really add these in):
$_GET['sort'] -->> gives you the column name of the table to sort
$_GET['order'] -->> specifies the order i.e, ASC or DESC
$_GET['search']-->> gives the text to search into database
$_GET['limit']-->> specifies number of rows
$_GET['offset']-->> starting position / offset in table

For those in need of a guide make sure your php file that contains the sql queries makes use of these variables (depending on the situation i.e apply $_GET['sort'] and $_GET['order'] in your query in the sql order: ORDER BY $sort $order) and run the query when the situation arises:

if (isset($_GET['sort'])) {
//sql sort query here
} else {
//return default table
}

...now for the search and export features...

@dabros
Copy link
Contributor

dabros commented Mar 28, 2016

@nyarachm - those are in the documentation, very clearly detailed in queryParams which itself is referanced in several related items and examples.

http://bootstrap-table.wenzhixin.net.cn/documentation/#table-options

It could be more prominent there perhaps, but it shouldnt need to be given that skimming the short descriptions should flag it, and more importantly your expected to know how to hit F12 and view network requests, as I directed you to earlier.

Glad that you got it working, but if you dont understand the steps someone tells you to find something then say that, so you can improve your ability to improve yourself

Web inspector/developer tools are critical to this kind of work, so make sure you get familiar with using them too as they will help you a lot.

@isaac-peka
Copy link
Contributor

isaac-peka commented Apr 22, 2016

I'm also hitting the same problem with the export function not working with data-side-pagination="server". It always exports the contents of the current rows in-view, rather than those that are selected. Do you know if there is there a way to resolve this or is it a known limitation of the export plugin?

Happy to provide a jsfiddle or open a new issue if needed. If it's a known limitation, also happy to whip up a quick PR.

@dabros
Copy link
Contributor

dabros commented Apr 26, 2016

@sampeka - please try not to post in other topics on same issue without linking

ref #2220

@isaac-peka
Copy link
Contributor

@dabros, apologies - my bad, I opened the new issue for a clearer title and a more focused subject, but if you'd rather track the issue here I'll close it.

@dabros
Copy link
Contributor

dabros commented Apr 26, 2016

@sampeka - its better you opened new issue, and i like the added clarity, just remember to backlink to related topics (from either side), especially if you posted same question : )

@wenzhixin wenzhixin added export Issues for the export extension. and removed export Issues for the export extension. labels Apr 28, 2016
@wenzhixin
Copy link
Owner

Fixed in #3830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
export Issues for the export extension.
Projects
None yet
Development

No branches or pull requests

4 participants