页面上是否可以有多个 Kendo UI 网格? 编辑:网格必须同时可见。
对于我过去尝试过的一些 jQuery 网格,一页上不可能有多个网格实例,因为网格分配给其子 DOM 元素的 ID 没有以网格 id 为前缀;页面上有多个网格将创建两个或多个具有相同 ID 的 DOM 元素。
最佳答案
是的,我已经在我的项目中实现了这一点,没有出现您提到的任何问题。我在一页中有 3 个网格。
更新:基本小部件元素具有您自己分配的任何 ID。至于子元素,它们不使用ID,而是使用数据属性。我在整个网格中没有看到任何 ID。以下是我的一个网格中表标题的示例:
<thead class="k-reorderable" data-role="reorderable">
<tr>
<th class="k-header" data-title="Service name" data-field="Name" role="columnheader" data-role="sortable">
<a class="k-link" href="#">Service name</a>
</th>
<th class="k-header" data-title="Lasting time" data-field="LastingTime" role="columnheader" data-role="sortable">
<a class="k-link" href="#">Lasting time</a>
</th>
<th class="k-header" data-title="Price" data-field="Price" role="columnheader" data-role="sortable">
<a class="k-link" href="#">Price</a>
</th>
</tr>
</thead>
数据行使用 UID 来区分自己,这是另一个示例:
<tr class="k-alt" role="row" data-uid="f2cd4f59-8492-4616-8fc6-5d65ec466437">
<td role="gridcell">Test</td>
<td role="gridcell">01:00:00</td>
<td role="gridcell">500</td>
</tr>
我建议您查看 http://demos.kendoui.com/ 上的示例并检查网格生成的 html 以获取更多详细信息。
我认为您不应该直接通过 DOM 访问特定的子元素。我建议坚持使用小部件 API,这就是它存在的原因。
希望这有帮助!
关于grid - 剑道 UI 网格 : is it possible to have more than one grid on the page without element ID collisions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13869535/