ajax 提取的数据仅在 IE9 浏览器中的表格中显示,单元格之间显示空白(或空白),

发布于 2024-11-08 04:50:00 字数 844 浏览 3 评论 0原文

正如标题所示,我有一个从数据库加载的表。首先仅获取 15 行。后来有办法让它显示 15 、 50 和 100 条记录来使用下拉列表显示。这是通过ajax获取的。如果我使获取记录计数超过 59 或以上,则会在随机行的单元格之间创建空白空间。仅在 IE9 浏览器中发生。 IE浏览器版本< 9 都不错,FireFox、Chrome、Safari 也不错。这是我的第一个问题,所以我不允许发布图像,所以我将在下面放置一些数字形式。

|..1..||..2..||...3...||....4....||.5.||..6..||..7 ..|

我们假设上面是一行,条形充当左右边框。我在 IE9 ajax 获取的数据中得到的内容类似于下面的

|..1..||..2..||...3...||....4....||.5。 ||..6..||..7..|

|..1..|_ _ _|..2..||...3...||....4....||.5.||..6..|| ..7..|

|..1..||..2..||...3...||....4....||.5.||..6..||..7 ..|

|..1..||..2..||...3...|_ _ _ _|....4....||.5.||..6..| |..7..|

|..1..||..2..||...3...||....4....||.5.||..6..||..7 ..|

您会在第二行(第一列之后)和第四行(第三列之后)看到空格(由_'下划线'表示)。我没有任何想法,因为 IE 开发人员/调试器工具栏没有多大帮助。效果不是随机的,因为我在刷新时或清除缓存后在单元格之间得到相同的空白空间。可能是因为ajax获取的数据与IE9渲染有关?有没有人遇到过这样的问题或类似的问题。任何帮助将不胜感激。

As the title suggest, I have a table which is loaded from database. First only 15 rows are fetched. Later there is way to make it show 15 , 50 and 100 records to show using dropdown list. Which is fetched via ajax. Some how if I make the fetch record count more than 59 or above, empty space is created in between cell at random row. It happens only in IE9 browsers. IE Browsers version< 9 are good, FireFox, Chrome, Safari are good as well. This is my first question so I'm not allowed to post image, so I'll put some numeric forms below.

|..1..||..2..||...3...||....4....||.5.||..6..||..7..|

Let's assume the above is a row,the bar acting as border right and left. What I get in IE9 ajax fetched data is something like below

|..1..||..2..||...3...||....4....||.5.||..6..||..7..|

|..1..|_ _ _|..2..||...3...||....4....||.5.||..6..||..7..|

|..1..||..2..||...3...||....4....||.5.||..6..||..7..|

|..1..||..2..||...3...|_ _ _ _|....4....||.5.||..6..||..7..|

|..1..||..2..||...3...||....4....||.5.||..6..||..7..|

You see the space (represented by _ 'underscore') in the 2nd ( after 1st column)and 4th (after 3rd column) row. I am not getting any idea, as the IE developer/debugger toolbar isn't helping much. The effect is not random as I get the same empty space between cell on refresh or after clear cache. Might it be due to ajax fetched data has something to do with IE9 rendering it? Did anyone face any such problem or a close one. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

超可爱的懒熊 2024-11-15 04:50:00

dhiraj - MS 似乎没有关于这个 IE9 错误的任何官方声明,但我不止一次经历过它。它似乎与源代码中表格行和单元格之间的空白有关,并且仅发生在 ajax 回发后在 UpdatePanels 中呈现的表格上。我找到了解决该问题的(丑陋的)方法。

如果您使用 ListView 控件,您将能够删除表结构中的空格。不幸的是,它使您的源代码更加难以阅读,但它似乎确实解决了问题。因此,例如,如果您的原始代码如下所示:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
    </table>
</LayoutTemplate>
<ItemTemplate>
    <tr>
        <td><%# Eval("field1") %></td>
        <td><%# Eval("field2") %></td>
        <td><%# Eval("field3") %></td>
        <td><%# Eval("field4") %></td>
    </tr>
</ItemTemplate>

您的“固定”代码需要如下所示:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table><asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder></table>
</LayoutTemplate>
<ItemTemplate>
    <tr><td><%# Eval("field1") %></td><td><%# Eval("field2") %></td><td><%# Eval("field3") %></td><td><%# Eval("field4") %></td></tr>
</ItemTemplate>

希望这有帮助!

dhiraj - There does not seem to be any official statement about this IE9 bug from MS but I have experienced it on more than one occasion. It seems to be related to the whitespace between table rows and cells in the source code and only happens on tables that are rendered in UpdatePanels after an ajax postback. I have found an (ugly) fix for the problem.

If you use a ListView control, you will have the ability to remove the whitespace in your table structure. Unfortunately it makes your source code more unreadable, but it does seem to fix the problem. So, for example, if your original code looked like this:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
    </table>
</LayoutTemplate>
<ItemTemplate>
    <tr>
        <td><%# Eval("field1") %></td>
        <td><%# Eval("field2") %></td>
        <td><%# Eval("field3") %></td>
        <td><%# Eval("field4") %></td>
    </tr>
</ItemTemplate>

Your "fixed" code would need to look like this:

<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
    <table><asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder></table>
</LayoutTemplate>
<ItemTemplate>
    <tr><td><%# Eval("field1") %></td><td><%# Eval("field2") %></td><td><%# Eval("field3") %></td><td><%# Eval("field4") %></td></tr>
</ItemTemplate>

Hope this helps!

习惯成性 2024-11-15 04:50:00

我想补充一点,我也遇到了完全相同的问题。

通过 AJAX 加载表格会导致 TD 元素之间出现随机间隙。

呈现此表的代码是:

echo("  <tr>")
echo("      <td>Column1</td>")
echo("      <td>Column2</td>")
echo("      <td>Column3</td>")
echo("      <td>Column4</td>")
echo("      <td>Column5</td>")
echo("  </tr>")

echo() 是response.write 的简单包装器。

正如此处评论中所建议的,我只是删除了响应中的空白,如下所示:

echo("<tr>")
echo("<td>Column1</td>")
echo("<td>Column2</td>")
echo("<td>Column3</td>")
echo("<td>Column4</td>")
echo("<td>Column5</td>")
echo("</tr>")

这立即解决了问题,丑陋的标记,但表格现在呈现一致。 Deffo IE9 中的一个错误

I'd just like to add that i had the exact same problem.

Loading a table in via AJAX resulted in random gaps between TD elements.

Code that rendered this table was:

echo("  <tr>")
echo("      <td>Column1</td>")
echo("      <td>Column2</td>")
echo("      <td>Column3</td>")
echo("      <td>Column4</td>")
echo("      <td>Column5</td>")
echo("  </tr>")

echo() being a simple wrapper for response.write.

As suggested in the comments here, i simply removed the white space on the response as follows:

echo("<tr>")
echo("<td>Column1</td>")
echo("<td>Column2</td>")
echo("<td>Column3</td>")
echo("<td>Column4</td>")
echo("<td>Column5</td>")
echo("</tr>")

This immediately solved the problem, ugly markup but table now renders consistently. Deffo a bug in IE9

旧街凉风 2024-11-15 04:50:00

尝试将标签的内容放在标签

Try to place the contents of the tag <td> in tag <div>

残疾 2024-11-15 04:50:00

我也有同样的问题。回发后更新面板中 IE9 中单元格之间的随机间隔。

就像其他人建议的那样,删除表格单元格元素之间的空格。它有点难看,但似乎确实有效!

从这个...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
</tr>

到这个...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td>
</tr>

为我解决了问题!它似乎只是表数据元素之间的间距,因此您不必将整个表行放在一行标记上。

I had the same problem. Random spacer between cells in IE9 in an update panel after a postback.

Like others have suggested, remove the spaces between the table cell elements. It's a little ugly but it does seem to work!

from this...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
   <td>
      <%--Cell Contents --%>
   </td>
</tr>

to this...

<tr class="rpt-row-alt">
   <td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td><td>
      <%--Cell Contents --%>
   </td>
</tr>

Solved the problem for me! It only seems to be the spacing between the Table Data elements so you don't have to have the whole table row on one line of mark up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文