Comments (20)
Same problem - must specify scrollX=TRUE
.
from dt.
I just tested your configurations, and I realized you'd have to use
autoWidth = TRUE
inoptions
to makewidth
work.In your second example, I guess you cannot make the width of all three columns to be 40%, since 40 * 3 = 120%.
These suggestions do not seem to work when building an HTML markdown document. My table contains rather long texts, and the last column occupies like 50% of all the table, and I can't adjust it.
datatable( covered_tbl , rownames = F , escape = F , options = list( pageLength = 10 , scrollX = T , scrollY = T , autoWidth = T , columnDefs = list( list(targets=c(0), visible=TRUE, width='10%'), list(targets=c(1), visible=TRUE, width='10%'), list(targets=c(2), visible=TRUE, width='4%'), list(targets=c(3), visible=TRUE, width='38%'), list(targets=c(4), visible=TRUE, width='38%') ) ) )
from dt.
Does not work in my hand, do I miss something?:
library(DT)
DeptEditDT <- datatable(
iris, rownames=FALSE,
extensions = list(Scroller=NULL, FixedColumns=list(leftColumns=2)),
options = list(
dom = 'T<"clear">lfrtip',
autoWidth = TRUE,
columnDefs = list(list(width = '20%', targets = list(2,3,4))),
deferRender=TRUE,
scrollX=TRUE,scrollY=400,
scrollCollapse=TRUE,
pageLength = 100, lengthMenu = c(10,50,100,200)
)
)
DeptEditDT
from dt.
I just tested your configurations, and I realized you'd have to use autoWidth = TRUE
in options
to make width
work.
In your second example, I guess you cannot make the width of all three columns to be 40%, since 40 * 3 = 120%.
from dt.
I don't suppose there is a way to change column widths without specifying scrollX = TRUE
? For larger page lengths, this puts the scroller all the way at the bottom. Some users might not even know there is a scroller all the way at the bottom of the table.
from dt.
Yep. Works now. Thanks!
from dt.
I tried to use your code to control the column width. I realized that if leave out the options: scrollX=TRUE,scrollY=400. Then it doesn't work. Don't know why.
from dt.
Yep, same for me as @zizaozi (above). Should it be necessary to specify these params too?
from dt.
Same as ??
from dt.
I just want to add that I've been trying to debug this column width problem for a few days until I stumbled on this thread. Specifying scrollX=TRUE
fixed all my issues. Thank you all for the help.
from dt.
Same here, adding scrollX = TRUE
in the options list solves the problem.
from dt.
Is there no way you can avoid scrollX = TRUE to be able to control the width - as tsouchlarakis points out, that for larger page lengths, this puts the scroller all the way at the bottom which is problematic.
from dt.
When I use scrollX=T
this severely decrease width of my entire table to half the page and only half columns are now visible, however it does work for extending the column I wanted but have to scroll ALLLLLL the way over now to see half my columns. What happened? Without scollX the table is correctly the width of the screen.
from dt.
Neither adding scrollX=TRUE
or scrollX=FALSE
disables the horizontal scroller nor adjusts the column widths for me. Also if I give width = "600px"
as an overall datatable option, the table is confined to a much smaller width (than 600px) and the X scroller invariabley appears regardless of scrollX=FALSE. I know there is a known issue and read through it but the workaround also doesn't seem to work.
from dt.
workaround for datatables with not too much datas:
datas<- ( datas
%>% mutate (
# you could also use a css class and / or add a div only for length string greater than n characters
mycol1=paste0("<div style='white-space: normal;width: 50px;'>",mycol1,"</div>")
)
)
escape_vector<- -(which(colnames(datas) %in% list("mycol1","mycol2" )) +1)
res<-DT::datatable( datas,
style = "bootstrap", class = "compact", filter='top',
selection = c("single"),
escape= escape_vector,
[...]
from dt.
These suggestions do not seem to work when building an HTML markdown document. My table contains rather long texts, and the last column occupies like 50% of all the table, and I can't adjust it.
I am also building a table in an HTML markdown document and haven't been able to get any of these suggestions to work to change the widths of my columns.
from dt.
None of these suggestions are working for me either. The width of the column does not change regardless of the things listed here.
from dt.
This works for me.
DT::datatable(iris, options = list(columnDefs = list(list(targets = (3), width = "50%"))))
from dt.
That also works for me. But for some reason it is not working with my data:
df <- structure(list(pageTitle = c("oi r—ovn nngenWYeion iP 0m corMiokgfrn mneCuoJW Kof oET rmao5orntnanOimtfe",
"dsote rPVertsoies’ n e nasnuRge O assOClInABsnIt1Dtor used9-nieg aetsMaC erlnolpVasu ",
"pgnhyToou hiftMtA yCoHi eheolEc o tn AeurlSonllrdct in f aondWtaOaefuaogrsdas",
"AniiseMagee ecSEtaCoortse nfig c:ganl stu aoctrr iientenAInioSa hnnnrsn urdce Juiitcolrlci",
"sStnas C PssruslAM eardnVlEmsn:tinrtte in nAigtlaTeIas Aaeye etegs",
"omogdai ea en yerro CiiD Aoy pl fdioienlBtclsaTBahAcafrxmdo tnrfeoet",
"a deneayithegabteatcsNr eP innsoAaeietetuno ra S nCcCMad nueRrnloernaces ninsisaml o PoewllAc",
"l—hccntDic itnWvtaoIe sAoaatupluaY ngTannC AYatplo in?no ureeri: ",
" PaefrbMleieirmpsmaeyen l ngeisBrai CEcrKlmLrSeE eaAnN",
"a odHFegoatDdiStAoh ornmmsniultYyMoiisly i-te gitesun ", "WGW eerkRNetneet rwiwouAcodsaaas rG rirFdeea mDrlnauesvoinGtu mk nsatAd",
"ice clIrsogtlftCniBA rrandhnP:neeFtP oeanneaPoto esCestara prasotS Ba tev en Aa",
" l tahddotnrt:FiSessaRGta Bwdeaaur Ianntg c retd auWUreuegDA ",
"ast utisyWi:va ioteepohn reFll gIrnsdAdlUoe iitwhft stgrSs wnn aDagBedna",
"Vmm Ts erlOoaiceeCe t AEiB i9snaeiaeR niC e ukCrnneoat kkn ne1DPXfe- sCasOrFoOIPsnduthioicdraumtln"
), published = structure(c(18691, 18338, 18082, 18345, 18942,
18967, 18843, 18039, 18683, 18366, 18232, 19026, 18974, 17667,
18589), class = "Date"), views_all_time = c(125, 77, 63, 190,
158, 126, 98, 94, 77, 203, 75, 50, 148, 125, 49), views_zach_start = c(6,
12, 9, 9, 158, 126, 25, 9, 18, 11, 6, 50, 148, 27, 6), views_past30 = c(3,
6, 3, 3, 12, 23, 15, 3, 9, 3, 3, 50, 46, 9, 3), views_past7 = c(0,
3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 50, 0, 3, 0), views_this_week = c(0,
0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 6, 0, 0, 0)), row.names = c(NA,
-15L), class = c("tbl_df", "tbl", "data.frame"))
DT::datatable(iris,
extensions = "Scroller",
options = list(columnDefs = list(list(
targets = (0), width = "50%"
)),
deferRender = TRUE,
scrollY = 200,
scroller = TRUE))
DT::datatable(df,
extensions = "Scroller",
options = list(columnDefs = list(list(
targets = (0), width = "10%"
)),
deferRender = TRUE,
scrollY = 200,
scroller = TRUE))
DT::datatable(df,
extensions = "Scroller",
options = list(columnDefs = list(list(
targets = (0), width = "50%"
)),
deferRender = TRUE,
scrollY = 200,
scroller = TRUE))
from dt.
I just tested your configurations, and I realized you'd have to use
autoWidth = TRUE
inoptions
to makewidth
work.
In your second example, I guess you cannot make the width of all three columns to be 40%, since 40 * 3 = 120%.These suggestions do not seem to work when building an HTML markdown document. My table contains rather long texts, and the last column occupies like 50% of all the table, and I can't adjust it.
datatable( covered_tbl , rownames = F , escape = F , options = list( pageLength = 10 , scrollX = T , scrollY = T , autoWidth = T , columnDefs = list( list(targets=c(0), visible=TRUE, width='10%'), list(targets=c(1), visible=TRUE, width='10%'), list(targets=c(2), visible=TRUE, width='4%'), list(targets=c(3), visible=TRUE, width='38%'), list(targets=c(4), visible=TRUE, width='38%') ) ) )
Just the same for me. No matter what I have tried (everything mention here and elsewhere), with HTML markdown nothing works to obtain an specific width.
Is there any solution?
Thank you
from dt.
Related Issues (20)
- two "remove" icons in filtered filter = 'top'? HOT 2
- plugins = 'natural' not working for DT v > .27? HOT 3
- 503 error with very large http cookies
- Issue using `replaceData()` with `dataTableProxy()` HOT 4
- `formatStyle()` doesn't work with Bootstrap 5 HOT 5
- Cannot be rendered correctly in Shiny app with tailwind css HOT 3
- some selected rows loose bg (bootstrap 5, rowGroup extension, selection)
- Selection of multiple levels HOT 2
- [Accessibility] Trigger custom row select from Javascript callback HOT 11
- R shiny DT table with pagination and drop down list inside table and being able to save the entire updated table as csv file HOT 5
- DT 0.31 breaks previous 'ignore colnames' behavior during `replaceData()` HOT 1
- RowGroup extension with rownames = TRUE HOT 6
- updateSearch does not update numeric slider values
- datatable column filters clash with shiny::selectizeInput when invoked first HOT 4
- DateTime date picker CSS is broken in SearchBuilder
- Disabling editable table by row (and not just by column)
- autoFill extension returns `NaN` instead of incrementing HOT 5
- Docs do not state whether shift+click works for multi-row selection
- #828 breaks maintaining selected columns upon re-render HOT 3
- signif() + datatable() bug HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dt.