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

custom dataTablesJSON #66

Closed
vnijs opened this issue May 6, 2015 · 7 comments
Closed

custom dataTablesJSON #66

vnijs opened this issue May 6, 2015 · 7 comments

Comments

@vnijs
Copy link
Contributor

vnijs commented May 6, 2015

I can see how to create my own version of dataTablesJSON but I'm not sure how to get DT to use it. Could dataTableAjax take a function as an argument?

A related question if about ranges. dataTablesJSON seems to use commaToRange but the filter boxes use '...' instead. Could you explain how this work?

My question is related to #50
@kismsu Could you perhaps share your example?

@yihui
Copy link
Member

yihui commented May 6, 2015

... is just used for the presentation purpose; internally the two values of the range are joined by , before they are sent to the server: https://github.com/rstudio/DT/blob/9f5f0e5478ac2/inst/htmlwidgets/datatables.js#L203

And yes, I can add a function argument to dataTableAjax() that defaults to dataTablesJSON if you want.

@vnijs
Copy link
Contributor Author

vnijs commented May 6, 2015

Ah. I seem to recall that both , 5 and 5, used to work in shiny::datatables. ... 5 works but not 5 .... To be honest, I would probably prefer using ,. There is not a lot of space in these boxes when you have 10+ columns :)

By the way, there is no option to hide the remove glyph at this time correct?

If there is an alternative way to get DT to use 'my' function that is fine. I just couldn't figure out how to do it. If you are ok with changing dataTableAjax that works for me.

Thanks Yihui!

@yihui
Copy link
Member

yihui commented May 6, 2015

You are right. I have not addressed the issue of the crowded search boxes yet.

For ,5 and 5,, I guess they are no longer necessary in DT, because in these cases, the missing end will be automatically replaced by the min or max. (If it is not, it must be a bug)

@vnijs
Copy link
Contributor Author

vnijs commented May 6, 2015

How does DT know what end is missing? It still needs ... (or , ) right? If so, then , might be preferable.

... 5000 is converted to 338.00 ... 5000.00 but 5000 ... is converted to 5000.00 ... 5000.00. You can try at link below (Data > View tab):

https://vnijs.shinyapps.io/base/

@yihui
Copy link
Member

yihui commented May 6, 2015

That is a bug. Should be fixed now.

@vnijs
Copy link
Contributor Author

vnijs commented May 7, 2015

Works! Are you open to changing the ... to , and hiding the remove glyph? If so do you prefer a pull request?

@yihui
Copy link
Member

yihui commented May 24, 2015

I have added a filter argument to dataTablesAjax(), but please note it is different with the old dataTablesJSON(), since I don't want everybody to copy the code that parses the Ajax parameters from the HTTP request and returns the HTTP response with encoded data. I have prepared the parameters as a list, and will do JSON encoding for the list returned from your custom filter function.

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

No branches or pull requests

2 participants