简体   繁体   English

元素不想绝对定位,ag-Grid 中的自定义单元格编辑器

[英]Element does not want to be positioned absolutely, custom cell editor in ag-Grid

I have written a custom ag-Grid cellEditor, the cellEditor is setup as a popup and has an input field that acts as search/filter input for selection box below it.我编写了一个自定义的 ag-Grid cellEditor,cellEditor 被设置为一个弹出窗口,并有一个输入字段,作为其下方选择框的搜索/过滤器输入。

The issue I have is the absolute position seems to work for the vertical position of the popup, but not the horizontal position.我遇到的问题是绝对位置似乎适用于弹出窗口的垂直位置,但不适用于水平位置。 If the popup is too wide for the underlying grid, it will push my input field to a different position (typically to the left).如果弹出窗口对于底层网格来说太宽,它会将我的输入字段推到不同的位置(通常在左侧)。

I have a stackblitz example where the most left column (city) has a correctly positioned input field when editing, but the most right column (accommodation) has an input field that is positioned to the left.我有一个 stackblitz 示例,其中最左边的列(城市)在编辑时有一个正确定位的输入字段,但最右边的列(住宿)有一个位于左侧的输入字段。

https://stackblitz.com/edit/ag-grid-auto-complete https://stackblitz.com/edit/ag-grid-auto-complete

Below it is correctly positioned:在它下面正确定位: 正确定位 Here below it is incorrectly positioned, it should overlap the cell of the underlying grid (the cell showing "Rental").下面它的位置不正确,它应该与底层网格的单元格(显示“租赁”的单元格)重叠。 定位不正确

Is there something wrong in my css positioning, is this caused my ag-Grid in the underlying grid?我的 css 定位是否有问题,这是导致我在底层网格中的 ag-Grid 吗? More importantly, how can I control the positioning of the cellEditor so that my input field always overlaps with the underlying cell that is edited?更重要的是,如何控制 cellEditor 的位置,以便我的输入字段始终与被编辑的底层单元格重叠?

Source also available at https://github.com/superman-lopez/ag-grid-auto-complete来源也可在https://github.com/superman-lopez/ag-grid-auto-complete 获得

It gets resolved once you remove its width from AutocompleteComponent .一旦您从AutocompleteComponent删除其宽度,它就会得到解决。

Before

 <ag-grid-angular style="width: 350px; max-height: 200px; font-weight: 200;"....>

After

 <ag-grid-angular style="max-height: 200px; font-weight: 200;"....>

Updated stackblitz 更新堆栈闪电战

I incorrectly used a <div> to apply styling to the component itself, while I should have used styling on the host (which is effectively the component).我错误地使用<div>将样式应用于组件本身,而我应该在host (实际上是组件)上使用样式。 More information about style encapsulation and host styling can be found at many resources such as https://blog.angular-university.io/angular-host-context/有关样式封装和host样式的更多信息可以在许多资源中找到,例如https://blog.angular-university.io/angular-host-context/

The stackblitz and the source mentioned in the question has been corrected to correctly use the styling.问题中提到的 stackblitz 和来源已更正以正确使用样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM