Hi,
I have a hierarchical grid that I am binding using knockout. The datasource I am using is made up of nested ViewModel objects, child tables represented as lists withing the parent record. I think I may be doing something incorrectly when binding the child tables and setting up the parent-child relationship. This seems to work file between the root level and the first level of children but from the second level on there seems to be issues. Included below is the table and view model source.
The specific error I'm getting is "Uncaught TypeError: Cannot set property 'SubMatrixId' of null".
The View Model objects are being created as:
MatrixRecord(RootLevel)
SubMatrixRecord(Level 1)
PlanningItemRecord(Level 2)
Table Definition
--------------------------------------------------------------------
<table id="gridMatrix" data-bind="
igHierarchicalGrid: {
dataSource: matrixData,
primaryKey: 'MatrixId',
loadOnDemand: false,
width: 'auto',
autoGenerateColumns: false,
columns: [
{ key: 'MatrixId', headerText: 'Id', dataType: 'number' },
{ key: 'MatrixDesc', headerText: 'Description', dataType: 'string' }
],
features: [
{
name: 'Selection',
},
name: 'Paging',
type: 'local',
pageSize: 5,
name: 'Updating',
editMode: 'none'
}
columnLayouts: [
key: 'SubMatrices',
primaryKey: 'SubMatrixId',
foreignKey: 'MatrixId',
autoGenerateLayouts: false,
{ key: 'SubMatrixId', headerText: 'Id', dataType: 'number' },
{ key: 'SubMatrixDesc', headerText: 'Description', dataType: 'string' },
{ key: 'MatrixId', headerText: 'Matrix Id', dataType: 'number' }
key: 'Items',
primaryKey: 'ItemId',
foreignKey: 'SubMatrixId',
{ key: 'ItemId', headerText: 'Id', dataType: 'number' },
{ key: 'ItemDesc', headerText: 'Description', dataType: 'string' },
{ key: 'SubMatrixId', headerText: 'Sub Matrix Id', dataType: 'number' }
{ name: 'Selection'},
]
}">
View Model Definitions
function MatrixRecord(matrixId, matrixDesc, subMatrices) {
///<summary>
/// Represents a single root level
/// record entry in the matrix grid.
///</summary>
return {
MatrixId: ko.observable(matrixId),
MatrixDesc: ko.observable(matrixDesc),
SubMatrices: ko.observableArray(subMatrices)
};
function SubMatrixRecord(subMatrixId, subMatrixDesc, parentMatrixId, items) {
/// record entry in the Sub-Matrix grid. Also
/// represents a child level entry of the Matrix grid.
SubMatrixId: ko.observable(subMatrixId),
SubMatrixDesc: ko.observable(subMatrixDesc),
MatrixId: ko.observable(parentMatrixId),
Items: ko.observableArray(items)
function PlanningItemRecord(itemId, itemDesc, subMatrixId,
availableQty, sellingPrice, rotationCd, falloutPct,
ftcRegulatedInd, frozenInd) {
/// Represents a child level entry to the sub-matrix
/// record entry in both the Matrix and Sub-Matrix grids.
ItemId: ko.observable(itemId),
ItemDesc: ko.observable(itemDesc),
AvailableQty: ko.observable(availableQty),
SellingPrice: ko.observable(sellingPrice),
RotationCd: ko.observable(rotationCd),
FalloutPct: ko.observable(falloutPct),
FtcRegulatedInd: ko.observable(ftcRegulatedInd),
FrozenInd: ko.observable(frozenInd)
var MatrixViewModel = function() {
var self = this;
self.matrixData = ko.observableArray([]);
Thanks,
Chris.
Hello HSN Development,
Thank you for your patience while I was working on this issue. I was able to reproduce the issue you described which occurs when the foreign key value of a third level item has the same name as a property in a second level item (for example SubMartrixId). After testing, it appears that this was resolved in the latest service release, build 13.1.20131.2039.
While testing this I noticed two other issues occurring due to the naming properties in the model objects. The first issue is when model collections for each level have the same properties and this was logged as 141495 in out system. The second issue occurs when all the properties are different and this was logged as 141494.
I have created a private case and will be using it to send you more information so you may track these fixes. Please let me know if you have any other questions that I can help you with.
I received word from our Developers. Currently, our igHierarchicalGrid does not support a datasource in which layouts are repeated in depth such as Parent -->child-->child. The igHierarchicaDataGrid works well with unique layer definitions such as Parent-->child--grandchild structure.
If you have any questions, please let me know as well.