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.
Thank you for your help Martin, I really appreciate your time. You and Jon Hogue really helped a lot. Take care.
Hello Jason,
Let me know if you need further assistance regarding this subject.
Best regards,Martin PavlovInfragistics, Inc.
Hello Jason,Please excuse me if I'm not going in the right direction (what I understand is that a user should have multiple groups).You already achieved this scenario with the following model: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; }public List GroupInformation = new List();
}However I see that in one of your previous replies you defined a third column layout - "GroupName". If that's the case then you'll need one more class:public class SomeClassForTheThirdBand{ public string Field1 { get; set; } public string Field2 { get; set; }}In this case the definition for the "SomeClassForTheSecondBand" should be:public class SomeClassForTheSecondBand{ //public string GroupName { get; set; } public string GroupDescription { get; set; } public List GroupName = new List;}I'm attaching an MVC sample assembled from the information you provided
Hope this helps,Martin PavlovInfragistics, Inc.
Jason,
Thanks for posting the sample data. As Martin had mentioned, and as we discussed on the phone, the issue is with your child collection not being serialized from the .Net to the client. If you get that data into your data from the server, then you should have a working grid. Just make sure the name of the property with the child collections matches the key for the columnLayout.
Cheers,
Jon
var data = [{"Username":"Jason","Comment":"This is a comment for Jason","EmplID":"999999"},{"Username":"Jeff","Comment":"This is a comment for Jeff","EmplID":"888888"}]