I think I may have stumbled across a disconnect between your documentation and the actual implementation. This relates to v11.1, so it's possible you have already caught this and corrected it in later builds but I thought I'd mention it just in case...
I believe there is no way to explicitly specify the parentId field to use with a TreeGrid and it assumes that the first field with a foreignKey on the TreeGrid's datasource is the parentID.
However, see https://www.smartclient.com/smartcli...reeDataBinding, which says:
...and the following logic that doesn't quite implement this approach. It instead uses the first field with a foreignKey attribute, not the (first) field with a foreignKey attribute that points to the primaryKey field:
The effect of this for me is as follows (I'll be working around this now that I've identified ).
Since our datasources go through some transformation dynamic loading, the first such field in the base definition of our MerchandiseHierarchyGroup datasource is ItemSellingRuleID and so the TreeGrid is picking up that fieldas being the parentIDField instead of the preferred parent field. That causes it to generate this invalid criteria in requests to fetch children of the expanded node and therefore returns the entire tree again:[
Regards,
Gary O'Donnell
I believe there is no way to explicitly specify the parentId field to use with a TreeGrid and it assumes that the first field with a foreignKey on the TreeGrid's datasource is the parentID.
However, see https://www.smartclient.com/smartcli...reeDataBinding, which says:
To declare the Tree.parentIdField, declare a DataSourceField.foreignKey field with the name of the primaryKey field.
...and the following logic that doesn't quite implement this approach. It instead uses the first field with a foreignKey attribute, not the (first) field with a foreignKey attribute that points to the primaryKey field:
Code:
[INDENT][B] getTreeRelationship : function (parentDS, foreignKeyFieldName, multiple) {[/B] [B] // make sure we have DS instance[/B] [B] if (isc.isA.String(parentDS)) parentDS = this.getSchema(parentDS);[/B] [B] // find multiple foreign key fields if requested[/B] [B] var foreignNames, targetNames;[/B] [B] if (multiple && parentDS) {[/B] [B] foreignNames = [];[/B] [B] targetNames = [];[/B] [B] }[/B] [B] // if the name of the foreignKey wasn't passed in, autodetect it by looking for the first[/B] [B] // field on this ds with a foreignKey pointing at the appropriate dataSource.[/B] [B] var fields = this.getFields();[/B] [B] if (foreignKeyFieldName == null) {[/B] [B] for (var fieldName in fields) {[/B] [B] var currentField = fields[fieldName];[/B] [B] if (currentField.foreignKey != null) {[/B] [B] // If we were passed no parentDS and no foreignKeyFieldName, always use the[/B] [B] // first field with a specified foreignKey[/B] [B] if (!parentDS ||[/B] [B] (parentDS.getID() == isc.DataSource.getForeignDSName(currentField, this)))[/B] [B] {[/B] [B] if (!foreignKeyFieldName) foreignKeyFieldName = fieldName;[/B] [B] // if we're not returning all the foreign key fields, bail out[/B] [B] if (foreignNames) foreignNames.add(fieldName);[/B] [B] else break;[/B] [B] }[/B] [B] }[/B] [B] }[/B] [B] } [etc..][/B][/INDENT]
Since our datasources go through some transformation dynamic loading, the first such field in the base definition of our MerchandiseHierarchyGroup datasource is ItemSellingRuleID and so the TreeGrid is picking up that fieldas being the parentIDField instead of the preferred parent field. That causes it to generate this invalid criteria in requests to fetch children of the expanded node and therefore returns the entire tree again:[
Code:
[INDENT][B]{[/B] [B] "actionURL":"http://127.0.0.1:8080/SmartMDMTest/coreiso/sc/IDACall",[/B] [B] "showPrompt":true,[/B] [B] "prompt":"Finding Records that match your criteria...",[/B] [B] "transport":"xmlHttpRequest",[/B] [B] "promptStyle":"cursor",[/B] [B] "bypassCache":true,[/B] [B] "data":{[/B] [B] "criteria":{[/B] [B] "ItemSellingRuleID":null[/B] [B] },[/B] [B] "operationConfig":{[/B] [B] "dataSource":"MerchandiseHierarchyGroup",[/B] [B] "repo":null,[/B] [B] "operationType":"fetch",[/B] [B] "textMatchStyle":"exact"[/B] [B] },[/B] [B] "componentId":"isc_TreeGrid_0",[/B] [B] "appID":"builtinApplication",[/B] [B] "operation":"fetchMerchTree",[/B] [B] "oldValues":{[/B] [B] "ItemSellingRuleID":null[/B] [B] },[/B] [B] "progressiveLoading":false,[/B] [B] "resultTreeIdField":"ItemSellingRuleID",[/B] [B] "resultTreeParentIdField":"ItemSellingRuleID"[/B] [B] }[/B] [B]}[/B][/INDENT]
Gary O'Donnell
Comment