Search code examples
javascriptextjstreeloaddata

ExtJs Error: no method 'loadData'


Im trying to load a tree with data but i get this error

Uncaught TypeError: Object [object Object] has no method 'loadData'

this is my code

function ReadTree() {
        try {
            objHandler.ReadAssets(function (serverResponse) {
                if (serverResponse.error == null) {
                    var result = serverResponse.result;
                    if (result.length > 2) {

                        treestore.loadData(Ext.decode(result));

                       }
                }
                else {
                    alert(serverResponse.error.message);
                }
            }); //eo serverResponse
        } //eo try
        catch (e) {
            alert(e.message);
        }
    }

Solution

  • TreeStore does not inherit from Ext.data.Store and thus does not have a loadData method. Both TreeStore and Store inherit from Ext.data.AbstractStore which defines a load method only. Therefore TreeStore has a load method, so I think you'll have to use that instead.