1

I creating simple tree with rest service on Extjs 4.1.
How can I change parentId property name from Ext.data.NodeInterface?

Here is my model:

Ext.define('Buildlife.model.Folder', { 
    extend:'Ext.data.Model', idProperty:'id',  
    fields:[
        {name:'id', type:'auto',defaultValue:null},
        {name:'name', type:'auto'},  
        {name:'files',type:'auto',convert:function(val,rec){
            for(var i in val){
                var each = val[i];
                Ext.apply(each,{
                    name: each.fileName,
                    leaf:true,
                    iconCls:'x-event-icon'
                });
                rec.appendChild(rec.createNode(each));
            } 
            return val;
        },defaultValue:null}
    ], 
    proxy:{
        type:'rest', 
        url:GlobalConf.contextPath+'/rest/folder', 
        reader:{type:'json', root:'children', successProperty:'success'}, 
        writer:{type:'json', root:'children', writeAllFields:false}, 
        listeners:{exception:GlobalConf.storeExceptionHandler}
    }
});

When I add child node, it send parent node as a parentId.

{
    "children": {
        "name": "test",
        "parentId": "4fc742f344aeac0cc87e6afa",
        "leaf ": false
        //etc.
    }
}

Is it possible to change it to customProperty such as:

{
    "children": {
        "name": "test",
        "customProperty": "4fc742f344aeac0cc87e6afa",
        "leaf ": false
        //etc.
    }
}
4

1 回答 1

2

Doesn't look like it. ParentId is part of the NodeInterface class which every tree node subclasses. You would have to override the 'decorate' static method listed here: http://docs.sencha.com/ext-js/4-1/source/NodeInterface.html#Ext-data-NodeInterface Also there is an updateInfo method that gets called after a node move that will try to set parentId property - so that must be changed too.

于 2012-06-04T05:53:31.737 回答