我有一个分层数据网格,可以从json调用中获取数据。但我对儿童乐队有疑问。我不知道它是代码还是如何在json调用的列表中显示数据。
<table id="hierarchicalGrid"></table>
<script type="text/javascript">
var data = @MyData.AsRawJson()
$("#hierarchicalGrid").igHierarchicalGrid({
dataSource: data,
odata: true,
initialDataBindDepth: -1,
autoGenerateLayouts: true,
autoGenerateColumns: false,
primaryKey: "Username",
columns:
[{ key: "Username", headerText: "Username", dataType: "string" },
{key: "EmplID", headerText: "EmplID", dataType: "string" },
{key: "Comment", headerText: "Comment", dataType: "string" }],
features:
[{name: 'Paging',
type: "local",
pageSize: 50},
{ name: "Resizing"},
{ name: 'ColumnMoving' }],
columnLayouts: [
{
key: "GroupName",
primaryKey: "GroupName",
foreignKey: "GroupMembers",
autoGenerateColumns: false,
columns: [
{ key: "GroupName", headerText: "UserName", dataType: "string", width: "100px" },
{ key: "GroupDescription", headerText: "GroupDescription", dataType: "string", width: "100px" },
{ key: "GroupMembers", headerText: "GroupMembers", dataType: "string", width: "100px" }
],
features: [
{
name: "Sorting",
type: "local"
}]
}]
});
</script>
数据如下
[username],[EmplID],[comment],[GroupName],[GroupDescription],[GroupMembers]
UserName,EmplID和Comment以每个用户名重复相同的值,而GroupName和GroupDescription的值继续是唯一的。 GroupMembers与UserName具有相同的数据。所有数据都来自一个视图,它是来自用户([用户名],[EmplID],[评论])和组([GroupName],[GroupDescription],[GroupMembers])的连接。我想为UserName,EmplID和Comment创建一行,就好像它是一个groupby,然后扩展子带将显示[GroupName]和[GroupDescription]。
当初始网格打开时,我会重复[username],[EmplID],[comment]的行,当我尝试扩展子带时,它会抛出错误消息显示:
Unable to get value of the property '_injectGrid': object is null or undefined.
为了它的价值,这是使用ServiceStack到Bootstrap在C#Razor页面上编写的。非常感谢任何和所有帮助。