I have a hierarchical data grid that receives data from a json call fine. But I have problems with the child band. I don't know if it is the code or how the data is presented within the list from the json call.
<script type="text/javascript">
var data = @MyAcesData.AsRawJson()
$("#hierarchicalGrid").igHierarchicalGrid({ dataSource: data, odata: true, initialDataBindDepth: 0, 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", autoGenerateLayouts: true, 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>
The data comes as follows
[username],[EmplID],[comment],[GroupName],[GroupDescription],[GroupMembers]
with UserName,EmplID, and Comment repeating with the same values per username while values for GroupName, and GroupDescription continue to be unique. GroupMembers has the same data as UserName. All of the data is coming from a view, which is a join from Users ([username],[EmplID],[comment]) and Groups ([GroupName],[GroupDescription],[GroupMembers]). I would like a single row for UserName,EmplID, and Comment as if it were a groupby then expanding the child band would show [GroupName] and [GroupDescription].
When the initial grid opens, I get repeating rows of [username],[EmplID],[comment] and when I try to expand the child band, it throws a errormessage displaying:
Unable to get value of the property '_injectGrid': object is null or undefined.
For what its worth, this is written on C# Razor pages using ServiceStack to Bootstrap. Any and all help is greatly appreciated.
Hello Jason,
Can you send me a sample that demonstrates your issue, so that I can test and debug it on my side? Thanks in advance.
Regards,
Tsanna
I don't know if there is a neat way of displaying the code, or at least I don't know where to host it. I say that because I believe part of the problem I'm having is how the data is presented to the grid. The data is coming from a json ServiceStack call, See below:
<table id="hierarchicalGrid"></table>
var data = @UserInformation.AsRawJson()
$("#hierarchicalGrid").igHierarchicalGrid({
datasourcetype: 'json',
dataSource: data,
odata: true,
initialDataBindDepth: 0,
autoGenerateLayouts: false,
autoGenerateColumns: false,
columns:
[{ key: "Username", dataType: "string", headerText: "Username" },
{ key: "EmplID", dataType: "string", headerText: "EmplID" },
{ key: "Comment", dataType: "string", headerText: "Comment" }],
columnLayouts: [
{
key: "GroupInformation",
childrenDataProperty: "GroupInformation",
columnLayouts:
[{ key: "GroupName",
autoGenerateColumns: true}]
}]
});
That is what my code looks like in its current format. Running this code gives me exactly what I want on the parent band. The child band errors out with the message:
"Microsoft JScript runtime error: Unable to get value of the property 'dataType': object is null or undefined"
The data is now give to the grid as rawjson is from a list from a class that has fields "UserName, EmplID, Comment, and a property as a list that has fields "GroupName and GroupDescription" for my child band which will have multiple rows per one row of parent band. The name of the list that holds the child band information is "mygroup"
Using your syntax above for the data, I don't understand how I would be able prepare multiple rows for the second band. I understand how I can query a table and put that information in the list for the first band, but I don't quite understand how I can organize that information for the second band in what seems to be without a "List of a List", which is what I tried and didn't work.
For example, using the example of my code I posted, it seems like what you are telling me to try is equivalent to:
public class SomeClassForTheFirstBand{
public string Username { get; set; }public string Fullname { get; set; }public string Comment { get; set; }public string Acctlocked { get; set; }public string EmplID { get; set; }
class SomeClassForTheSecondBand
public string GroupName { get; set; } public string GroupDescription { get; set; }
}
UserInformation.Add(new SomeClassForTheFirstBand() { Username = "Jason", EmplID = "999999", Comment = "This is a comment for Jason", New SomeClassForTheSecondBand() {GroupName = "FirstGroupForJason", GroupDescription = "Description of First Group "})
UserInformation.Add(new SomeClassForTheFirstBand() { Username = "Jason", EmplID = "999999", Comment = "This is a comment for Jason", New SomeClassForTheSecondBand() {GroupName = "SecondGroupForJason", GroupDescription = "Description of Second Group "})
[the rest of the below is the same as what is posted above]
So, For each child band information that is different within what would be the same parent band, the parent information repeats in the rest of the row. Am I understanding you correctly?
dataSourceType:'json',
primaryKey:"EmplID",
//responseDataKey: data,
columns:[{ key:"Username", dataType: "string", headerText: "Username" },
{ key:"EmplID", dataType: "string", headerText: "EmplID" },
{ key:"Comment", dataType: "string", headerText: "Comment" }],
key:
"MyGroup",
responseDataKey:
"data",
autoGenerateColumns:
false,
primaryKey:"GroupName",
foreignKey: "GroupMembers",
columns: [{ key:
"GroupName", headerText: "UserName", dataType: "string" },
{ key:"GroupDescription", headerText: "GroupDescription", dataType: "string" }]
var data = [{"Username":"Jason","Comment":"This is a comment for Jason","EmplID":"999999"},{"Username":"Jeff","Comment":"This is a comment for Jeff","EmplID":"888888"}]
Let me know if you need further assistance regarding this subject.
Best regards,Martin PavlovInfragistics, Inc.
Thank you for your help Martin, I really appreciate your time. You and Jon Hogue really helped a lot. Take care.