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

slickGrid column resizing not worked Properly in RTL #446

Closed
MaziarSangi opened this issue Oct 21, 2019 · 11 comments
Closed

slickGrid column resizing not worked Properly in RTL #446

MaziarSangi opened this issue Oct 21, 2019 · 11 comments

Comments

@MaziarSangi
Copy link

MaziarSangi commented Oct 21, 2019

Hello I Used SlickGrid in RTL Theme and When I resize the column width it wont resize the column in right way.

@6pac
Copy link
Owner

6pac commented Oct 21, 2019

You have just changed repos, so firstly just checking you are now using our repo's codebase.

@ghiscoding
Copy link
Collaborator

ghiscoding commented Jan 31, 2020

You might need this direction: rtl as pointed out in this Stack Oveflow question.

@NadavPopplewell
Copy link

I have set direction : rtl on the body tab,
the slickgrid columns display exactly the same as in LTR mode,
but the header row is misaligned (too much to the left)
seems to be a problem with

What is this 'RTL theme' that the first poster refers to?

thanks,
Nadav

@6pac
Copy link
Owner

6pac commented Sep 22, 2021

I suspect they just use direction: rtl as @ghiscoding said. We've never built in or tested RTL support explicitly in SlickGrid, but it's all just HTML. If you want to tweak and test, we're happy to incorporate any changes or alternate CSS.

@NadavPopplewell
Copy link

But it's not only CSS, is it?
There seems to be some logic in the javascript code that adds left:+/-1000px to the header
This seems to cause problems when the style is direction:RTL

@6pac
Copy link
Owner

6pac commented Sep 26, 2021

https://stackoverflow.com/questions/25172683/why-does-slickgrid-add-1000px-in-js-then-reverse-it-in-css-style

I'll help if I can but I have never used RTL languages, so I don't think I'm the best person to be testing that scenario. If you could provide a new RTL example, I'm happy to tweak elements of the grid where necessary to support the example in working correctly. Possibly RTL will be a new Slickgrid option?

@NadavPopplewell
Copy link

How do I add the RTL example?

@6pac
Copy link
Owner

6pac commented Sep 26, 2021

Start with an existing example page (you might be best with a fairly fully featured one, like 'model', and you might want to check additional features like grouping and have more than one example page). Just call them 'example4-model-RTL', for example.
You can create a PR to add them, or just tell me which ones and post the basic mods to the source and I'll add them to the repo. Then you can play with them and create a PR if you like, or just post code snippets until we're happy with the result, then I'll commit.

@MorDery
Copy link

MorDery commented Sep 29, 2021

can you help me to find where in the code is there a reference to resize columns (by dragging header columns), it doesn't work right in RTL

@6pac
Copy link
Owner

6pac commented Oct 1, 2021

All the resize column code is in setupColumnResize() in slick.grid.js. It's possible that it's only set up for right handed column adjustment, but I don't know how RTL affects CSS. For example, I'm not sure if .append() appends to the left under RTL. That would make sense. So the drag handle setup is probably OK, but perhaps the width adjustment code needs to have a RTL option section added.

Really, an example is needed so we can actually see how this works and play around with it.

@ghiscoding
Copy link
Collaborator

ghiscoding commented Aug 15, 2023

So I took another look at this and all you need is to create a CSS class named "rtl" and then assign it to both headerCssClass (for the header titles) and cssClass (for the cells) and that should be enough (option 1). There is also a second way to do it shown further down (option 2). For both cases, it's solvable with CSS but you will need to user either the (option 1) cssClass/headerCssClass OR (option 2) flex CSS with a custom formatter to wrap the cell texts in a span.

Option 1

<style>
.rtl {
  direction: rtl;
}
</style>
<script>
var columns = [
  {id: "title", name: "Title", field: "title", cssClass: "rtl", headerCssClass: "rtl"},
];
</script>

image

in our next v5, we'll add CSS variables to our default them so that you can change the CSS to display: inline-flex and also justify-content to flex-start (or flex-end) BUT going this route will require the user to wrap the .slick-cell text in a span because CSS does not allow ellipsis to work with display: flex on the same div.

Option 2 (already doable)

Technically speaking, you could already do that yourself with the current styling theme, just modify the CSS

<style>
.slick-header-column, 
.slick-cell {
  display: inline-flex;
  justify-content: flex-end;
  
  // hack to allow child element with ellipsis, see article below
  // https://css-tricks.com/using-flexbox-and-text-ellipsis-together/ 
  min-width: 0;
}
.slick-header-column .slick-column-name,
.slick-cell span.child-cell {
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
</style>
<script>
// Custom Formatter to wrap text content into a SPAN
// we can add ellipsis on a SPAN
function spanFormatter (row, cell, val) {
  return `<span class="child-text">${val}</span>`;
}

var columns = [
  {id: "title", name: "Title", field: "title", formatter: spanFormatter},
];
</script>

image

as you can see both implementation works and you can do any of these 2 options in your code today, choose the best option that fits your need.

Summary/Notes

These kind of questions would be better answered on Stack Overflow. Also note that the CSS stylesheets that comes with SlickGrid were only created as templates, the user can and should modify it to fit their needs.

I think this should solve the problem and so I think it's ok to close this issue... if that doesn't, well sorry but all maintainers of SlickGrid are using LTR syntax, so the best persons to fix these kind of RTL issues is you instead of us.

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

5 participants