4

I started using SlickGrid for one of my projects recently. In my grid I have about 4,000 rows and 6 columns. The issue is that columns 2 through 6 are not rendered for the first two rows. For the remaining rows all columns are rendered just fine. Furthermore, if I scroll down and up again, the missing columns for these rows become visible. In other words, I see the issue only when the page is first generated.

Digging through the source code, I found that the following lines are causing the issue. If I comment out the break, then the entire grid renders without any issues.

1407     // Do not render cells outside of the viewport.
1408      if (columnPosRight[Math.min(ii - 1, i + colspan - 1)] > range.leftPx) {
1409        if (columnPosLeft[i] > range.rightPx) {
1410          // All columns to the right are outside the range.
1411          break;
1412        }

It appears that these lines are trying to skip rendering of the columns that are outside the viewport. However, I do not understand why they think that columns 2-6 in my first two rows are outside the viewport (when they are clearly inside).

Unfortunately, I am not able to reproduce this issue in a small example. So I am hoping that someone can spot the issue from the description of the symptom. Please help.

4

1 回答 1

0

可能是您渲染的值中有一些特殊字符(即 <、> 等),您可以使用自定义格式化程序来转义这些字符:

function escapeHTMLFormatter(row, cell, value, columnDef, dataContext) {
    if (value == null) {
       return "";
    } else {
       return (value + "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    }
 }
于 2014-06-15T11:12:17.150 回答