【发布时间】:2011-06-30 20:27:46
【问题描述】:
我正在使用 Telerik MVC Grid 组件来呈现通过 ajax 填充的可分组网格。网格渲染得很好,排序和分页工作,ajax 刷新工作,但是当我尝试进行分组时,渲染就搞砸了。附件是网格分组前后的屏幕截图。
网格定义非常简单:
<div id="tabAccounts" class="tab_content">
@(Html.Telerik().Grid<SharedSimpleAccountListViewModel>()
.Name("AcctGrid")
.Columns(columns =>
{
columns.Bound(x => x.Number)
.HeaderHtmlAttributes(new { @style = "text-align: center;" })
.HtmlAttributes(new { @style = "text-align: center;" });
columns.Bound(x => x.ProviderOrganizationFriendlyName)
.Title("Provider");
columns.Bound(x => x.Name)
.Title("Account Name");
columns.Bound(x => x.BillingLocationName)
.Title("Location");
})
.Groupable()
.DataBinding(db => db.Ajax().Select("CustomerAccounts", "Customers", new { id = Model.Id }))
.Pageable(pager => pager.PageSize(50))
.Sortable()
)
</div>
控制器操作也很简单(我不会粘贴,因为它只是从存储库中检索)。我使用的是 Telerik 默认主题,因此没有自定义 CSS,并且我已确认页面中包含所需的脚本。
在分组后检查 HTML,似乎对表格进行了更改,但它没有为组添加表格行元素。这是分组尝试后存在的 HTML:
<table cellspacing="0">
<colgroup>
<col class="t-group-col">
<col><col><col><col>
</colgroup>
<thead class="t-grid-header">
<tr>
<th class="t-group-cell t-header"> </th>
<th style="text-align: center;" scope="col" class="t-header">
<a href="/Customers/Details/408?AcctGrid-orderBy=Number-asc" class="t-link">Number</a>
</th>
<th scope="col" class="t-header">
<a href="/Customers/Details/408?AcctGrid-orderBy=ProviderOrganizationFriendlyName-asc" class="t-link">Provider</a>
</th>
<th scope="col" class="t-header">
<a href="/Customers/Details/408?AcctGrid-orderBy=Name-asc" class="t-link">Account Name</a>
</th>
<th scope="col" class="t-header t-last-header">
<a href="/Customers/Details/408?AcctGrid-orderBy=BillingLocationName-asc" class="t-link">Location</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">00002</td>
<td>Acme</td>
<td>Test account 2 </td>
<td class="t-last">Location 2</td>
</tr>
<tr class="t-alt">
<td style="text-align: center;">00001</td>
<td>3M</td>
<td>Test account 1</td>
<td class="t-last">Location 1</td>
</tr>
</tbody>
</table>
有什么想法吗?
【问题讨论】:
-
糟糕...是的,我将其交叉发布到 Telerik 并且在复制之前没有擦洗。我已经找到了解决方案,我只需要组织它,然后我就可以在 SO 上发布它。
-
@Jush,咳咳……你有解决办法吗?我很想看看。
-
@Levitikon,检查我发布的答案。
标签: asp.net-mvc asp.net-mvc-3 telerik-mvc