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

Use Json instead of Json file #28

Open
Snowji-Yama opened this issue Jan 20, 2016 · 10 comments
Open

Use Json instead of Json file #28

Snowji-Yama opened this issue Jan 20, 2016 · 10 comments

Comments

@Snowji-Yama
Copy link

Hi,

I would like to use your plugin but I have a problem. In my app, I don't need to use a json file. Is it possible to send a json object directly in option instead of a file ?

I need :

data_url:
[ { name: 'Once Upon a Time in the West',
rating: '8.7',
director: 'Sergio Leone',
year: '1968',
actor: 'Henry Fonda' },
{ name: 'Terminator 2: Judgment Day',
rating: '8.6',
director: 'James Cameron',
year: '1991',
actor: 'Arnold Schwarzenegger' },
{ name: 'Braveheart',
rating: '8.4',
director: 'Mel Gibson',
year: '1995',
actor: 'Mel Gibson' },
{ name: 'Oldboy',
rating: '8.4',
director: 'Chan-wook Park',
year: '2003',
actor: 'Min-sik Choi' } ]

Instead of :
data_url: 'data/movies.json'

Thanks !

@jiren
Copy link
Member

jiren commented Jan 21, 2016

Use below code If you don't want to use data url.

 var st = StreamTable('#stream_table', {view: view },  your_json_data);

@Snowji-Yama
Copy link
Author

Ok but "your _json_data" will be streamed,100 by 100 for exemple, or full load, ?

@jiren
Copy link
Member

jiren commented Jan 21, 2016

No it will not be streamed. It will load all data once and enabled pagaination.

@Snowji-Yama
Copy link
Author

So there is not solution to stream with json object ? Not a solution with tempory file ? because in my app I can't create file. I have a php method who return a json and I can send it in my view, that's all.

@jiren
Copy link
Member

jiren commented Jan 21, 2016

You need to make a JSON api, which sends JSON data in response of data_url.
In example I have used JSON file to run table html page as static without any server.

@Snowji-Yama
Copy link
Author

I'm not sure to understand all. I can't change my process, I'm on Symfony and I call in my controller a WebServices who return a JSON. So I can transfer this JSON from my controller to my view. After I don't know to incorporate your streamtable, but I need it because I have lot of data. So if I can create a tempory file json it's goo, else, I don't know :(

@jiren
Copy link
Member

jiren commented Jan 21, 2016

Using webservice is a correct solution. Just pass your webservice url to streamtable options.

var st = StreamTable('#stream_table', {view: view,  data_url: "WEBSERVICE URL" }, []);

@Snowji-Yama
Copy link
Author

Even if the WS return the complete result ? It's StreamTable will stream step by step the complet result ?

@jiren
Copy link
Member

jiren commented Jan 21, 2016

In any case if you load all data at time then there is no use of streaming.
You can paginate your WS respose. Streamtable will send you a page records offset.

@Snowji-Yama
Copy link
Author

Ok, I will try. Thanks

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

No branches or pull requests

2 participants