本文介绍了触发重绘会导致列被隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个展示我问题的plnk: http://plnkr.co/edit/bXINbDBIMb0LbLitHGbl.

I have a plnk that demonstrates my issue: http://plnkr.co/edit/bXINbDBIMb0LbLitHGbl.

有一个任务列表,每个任务可以包含一个任务列表.任务只能是最高级别,也可以是一个父项,并且任务不能包含自身.

There is a list of Tasks, each Task can contain a list of Tasks. Tasks can only be a top level or have a single parent and a Task can not contain itself.

当我使用foreach绑定时,任务将保存"到正确的任务并按预期工作. (除了适用的功能)(保存的内容用引号引起来,因为除将任务推送到可观察的数组外,其他任务并未真正保存.)

When I use the foreach binding the tasks are "saved" to the correct task and works as expected. (Other than the footable features) (Saved is in quotes because Tasks are not really saved other than being pushed to the observable array.)

根据此答案: https://stackoverflow.com/a/20811414/2033294 我创建了一个自定义的Footable捆绑.直到我使用嵌套Tasks尝试该绑定为止,它的工作完全符合我的要求.

According to this answer: https://stackoverflow.com/a/20811414/2033294 I created a custom Footable binding. The binding was working exactly as I wanted until I tried it with nested Tasks.

要查看我想要的行为,请按添加任务",按确定",单击刚刚创建的任务,然后添加另一个任务或子任务.按确定",再次单击任务",然后看到子任务已按预期保存.

To see the behavior I want, push 'Add Task', push 'Ok', click on the Task that was just created and add another Task or subtask. Push 'Ok', click on the Task again and see that the subtask is saved as expected.

要查看问题,请更改

<tbody data-bind="foreach: items, delegatedHandler: 'click'">

<tbody data-bind="footable: items, delegatedHandler: 'click'">

重复上述步骤.您会看到子任务没有像您期望的那样保存".如果您按应用"然后添加一个子任务,它将显示正常工作,直到您将确定"推回到主列表,然后再次查看该任务.您会看到子任务没有真正推送到正确的数组.

repeat the steps above. You'll see that the subtasks are not "saved" as you'd expect. If you push 'Apply' and then add a subtask, it will appear to work until you push 'Ok' back to the main list and then view the Task again. You'll see that the subtask was not really pushed to the correct array.

我已将问题缩小到触发footable_redraw的位置.当我禁用该功能时,数据将按预期显示.页脚不会重绘,但至少知道我知道问题不在于基础数据或视图模型.

I have narrowed the problem down to where the footable_redraw is triggered. When I disable that, the data appears as expected. The footable doesn't redraw, but at least know I know that the problem is not the underlying data or viewmodel.

我已经在footable.js中找到了此代码的问题:(第615行)

I have tracked the problem down to this code in footable.js: (Line 615)

if (data.hide[breakpointName] === false) $column.show();
                else $column.hide();

因此,出于某种原因,这些列被设置为隐藏,我不确定如何设置它们以使其不隐藏.

So, for some reason the columns are being set to be hidden, I'm just not sure how to set them so they are not hidden.

我发现如果这样做:(在footableBinding.js中)

I have found that if I do: (in footableBinding.js)

footable.reset();
footable.init();

兴趣所在:

footable.redraw();

这给出了我所期望的行为,但这似乎并不是解决问题的正确方法.

This gives the behavior that I expect, but that doesn't seem like the proper way to resolve the problem.

推荐答案

对我来说同样的问题,只是在一个简单的表上.

Same problem for me but just on a simple table.

如果我没有将<ht>的属性数据隐藏"设置为平板电脑"或电话",则我的桌子被隐藏了.

If I've got no <ht> with an attribute "data-hide" to "tablet" or "phone", my table is hidden.

只需将一个<ht>与数据隐藏在一起,我的表就可见了.

Just have to put one <ht> with a data-hide and my table is visible.

看起来像个虫子.

这篇关于触发重绘会导致列被隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 08:08
查看更多