Closed ismirsehregal closed 10 months ago
Terrific! Thank you for this request.
remotes::install_github("stla/jsTreeR@gridsearch")
Awesome, looks great!
Yeah!
There's just one problem: one cannot use two grids in one app with search = TRUE
.
There's just one problem: one cannot use two grids in one app with
search = TRUE
.
I didn't try yet, but that should be possible now.
Yes, it works 👍
@stla I have a question regarding this feature:
How is the width of the search inputs determined?
When I'm using a grid without predefined width
, they no longer fit the column widths:
grid <- list(
columns = list(
list(
# width = 200,
header = "Product",
headerClass = "bolditalic yellow centered",
wideValueClass = "cssclass"
),
list(
# width = 150,
value = "price",
header = "Price",
wideValueClass = "cssclass",
headerClass = "bolditalic yellow centered",
wideCellClass = "centered"
),
list(
# width = 150,
value = "quantity",
header = "Quantity",
wideValueClass = "cssclass",
headerClass = "bolditalic yellow centered",
wideCellClass = "centered"
)
),
resizable = TRUE
# , width = 600
)
Edit: same issue, when providing relative css units:
grid <- list(
columns = list(
list(
width = "40vw",
header = "Product",
headerClass = "bolditalic yellow centered",
wideValueClass = "cssclass"
),
list(
width = "20vw",
value = "price",
header = "Price",
wideValueClass = "cssclass",
headerClass = "bolditalic yellow centered",
wideCellClass = "centered"
),
list(
width = "20vw",
value = "quantity",
header = "Quantity",
wideValueClass = "cssclass",
headerClass = "bolditalic yellow centered",
wideCellClass = "centered"
)
),
resizable = TRUE
# , width = 600
)
The width is determined by the value of width
which must be a number of pixels.
Stéphane, I just had a look. We can make it more flexible. Please check my PR.
Ah I forgot one thing. We need to check whether a number was passed by the user and append "px".
Should work fine now.
The doc of jstree-grid says:
width: width of the column in pixels.
Ah but there are some examples with percentages...
Yes, it seems the docs need an update. Relative units are working fine.
I tried and that really doesn't work well. 50% for a search box does not correspond to 50% for the corresponding column.
I tested it with my above example using vw
, which was working fine. I currently can't test with %. I'll check tomorrow.
Indeed, it works fine with vw
.
Mhm, yes I guess the input-width % has a different reference (parent of different size) than the columns. The viewport size on the other hand is the same for all elements.
I modified the PR to fix usage of %. I think an even better solution would be to place the search boxes below the header into the table. But yeah - more work.
Thanks for the PR.
I never tried the resizable option for the grid. It would be great if the search boxes followed the resizing.
I think this is not doable since there's no callback for the resizing, and no event triggered (the doc says nothing about that).
I created another PR: https://github.com/stla/jsTreeR/pull/21 which inserts the search boxes into the table below the header (my initial goal - just like DataTable does it).
This way we can simply set the width of the inputs to 100%.
Edit - the resizable option also works now:
Nice! Thank you!
Yesterday I forgot to replace a hard coded treeID wit el.id
in one of the classes used in my PR. I just fixed that.
When setting
search = TRUE
for ajstree()
using agrid
, the rows are no longer aligned (please find the example code below):I'm wondering if the (overall) search box can be placed above the table or column-wise search boxes as shown here can be realized instead (Maybe with an option to place the search boxes on top, but below the column titles, just like datatables column search) using the
searchColumn
function provided by the grid plugin: