添加/删除smartgwt treegrid数据时出错:“this.data.isGroupedOutput'为null或不是对象”

时间:2012-07-06 11:43:57

标签: smartgwt treegrid

我有一个treegrid,我有操作添加和删除。如果我在我的应用程序中的任何其他页面之前访问此页面,它工作正常。如果我第一次访问其他页面而不是访问此页面,则会收到以下错误:

13:39:46.403 [ERROR] [pifs] 13:39:46.402:XRP9:WARN:Log:Error:
''this.data.isGroupedOutput' is null or not an object'
in http://localhost:8080/pifs/pifs/sc/modules/ISC_Grids.js
at line 3065
ListGrid.regroup(_1=>undef)
ListGrid.dataChanged(_1=>"add", _2=>undef, _3=>24, _4=>Array[1], _5=>undef)
dataChangedObservation(operationType=>"add", originalRecord=>undef, rowNum=>24, updateData=>Array[1], filterChanged=>undef)
ResultSet.$e0(_1=>undef)
ResultSet.handleUpdate(_1=>"add", _2=>Array[1], _3=>false, _4=>Obj)
ResultSet.dataSourceDataChanged(_1=>Obj, _2=>Obj)
dataChangedObservation(dsResponse=>Obj, dsRequest=>Obj)
DataSource.updateCaches(_1=>Obj, _2=>Obj)
[c]DataSource.handleUpdate(_1=>Obj, _2=>Obj)
DataSource.fireResponseCallbacks(_1=>Obj, _2=>Obj, _3=>Obj, _4=>Obj)
DataSource.$65e(_1=>Array[1], _2=>Obj, _3=>Obj, _4=>Obj, _5=>Obj)
DataSource.$76b(_1=>Obj, _2=>Array[1], _3=>Obj)
[c]Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>[DataSource ID:lfm], _5=>undef) on [Class RPCManager]
Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>undef)
[c]RPCManager.__fireReplyCallback(_1=>Obj, _2=>Obj, _3=>Obj, _4=>Array[1])
[c]RPCManager.fireReplyCallbacks(_1=>Obj, _2=>Obj)
[c]RPCManager.performOperationReply(_1=>Obj, _2=>Obj)
[c]RPCManager.$67x(_1=>20)
[c]RPCManager.performTransactionReply(_1=>20, _2=>"//isc_RPCResponseStart-->[{data:[{id:637..."[248], _3=>undef)
callback(transactionNum=>20, results=>Obj, wd=>undef)
    "isc.RPCManager.performTransactionReply(transactionNum,results,wd)"
** recursed on [c]Class.fireCallback

com.smartgwt.client.core.JsObject$SGWT_WARN: 13:39:46.402:XRP9:WARN:Log:Error:
''this.data.isGroupedOutput' is null or not an object'
in http://localhost:8080/pifs/pifs/sc/modules/ISC_Grids.js
at line 3065
ListGrid.regroup(_1=>undef)
ListGrid.dataChanged(_1=>"add", _2=>undef, _3=>24, _4=>Array[1], _5=>undef)
dataChangedObservation(operationType=>"add", originalRecord=>undef, rowNum=>24, updateData=>Array[1], filterChanged=>undef)
ResultSet.$e0(_1=>undef)
ResultSet.handleUpdate(_1=>"add", _2=>Array[1], _3=>false, _4=>Obj)
ResultSet.dataSourceDataChanged(_1=>Obj, _2=>Obj)
dataChangedObservation(dsResponse=>Obj, dsRequest=>Obj)
DataSource.updateCaches(_1=>Obj, _2=>Obj)
[c]DataSource.handleUpdate(_1=>Obj, _2=>Obj)
DataSource.fireResponseCallbacks(_1=>Obj, _2=>Obj, _3=>Obj, _4=>Obj)
DataSource.$65e(_1=>Array[1], _2=>Obj, _3=>Obj, _4=>Obj, _5=>Obj)
DataSource.$76b(_1=>Obj, _2=>Array[1], _3=>Obj)
[c]Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>[DataSource ID:lfm], _5=>undef) on [Class RPCManager]
Class.fireCallback(_1=>Obj, _2=>"rpcResponse,data,rpcRequest", _3=>Array[3], _4=>undef)
[c]RPCManager.__fireReplyCallback(_1=>Obj, _2=>Obj, _3=>Obj, _4=>Array[1])
[c]RPCManager.fireReplyCallbacks(_1=>Obj, _2=>Obj)
[c]RPCManager.performOperationReply(_1=>Obj, _2=>Obj)
[c]RPCManager.$67x(_1=>20)
[c]RPCManager.performTransactionReply(_1=>20, _2=>"//isc_RPCResponseStart-->[{data:[{id:637..."[248], _3=>undef)
callback(transactionNum=>20, results=>Obj, wd=>undef)
    "isc.RPCManager.performTransactionReply(transactionNum,results,wd)"
** recursed on [c]Class.fireCallback
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)

请帮助!我尝试了一切,但这个错误还在这里......

这是treeGrid代码:

public Canvas getViewPanel() {


    VLayout mainLayout = getMainVlayout();

    setPanelTitle("Define LFM tree structure:", mainLayout);

    lfmDataSource = DataSource.get("lfm");


    ToolStrip gridEditControls = addToolStrip();

    treeGrid = new TreeGrid();

    treeGrid.setGridComponents(new Object[] {
            ListGridComponent.HEADER,
            ListGridComponent.BODY, 
            gridEditControls 
    });

    treeGrid.setCanEdit(true);
    treeGrid.setLoadDataOnDemand(false);
    treeGrid.setWidth("100%");
    treeGrid.setHeight("90%");

    treeGrid.setNodeIcon(null);
    treeGrid.setFolderIcon(null);
    treeGrid.setShowOpenIcons(false);
    treeGrid.setShowDropIcons(false);
    treeGrid.setClosedIconSuffix("-");

    treeGrid.setAlternateRecordStyles(true);

    treeGrid.setWarnOnRemoval(true);
    treeGrid.setEditEvent(ListGridEditEvent.DOUBLECLICK);

    treeGrid.setDataSource(lfmDataSource);
    treeGrid.setFetchOperation("firstFourLevelstFetch");
    treeGrid.setAddOperation("addLfm");
    treeGrid.setRemoveOperation("removeActivity");


    Criteria criteria = new Criteria("project", getParentHolder()
            .getProjectID());
    criteria.addCriteria("project_phase", project_phase);
    treeGrid.fetchData(criteria);
    //treeGrid.getTree().openAll();


    TreeGridField levelField = new TreeGridField("level", 250);
    levelField.setCanEdit(false);

    TreeGridField nameField = new TreeGridField("name");
    TreeGridField level_pathField = new TreeGridField("level_path", 100);

    treeGrid.setFields(levelField, level_pathField, nameField);


    mainLayout.addMember(treeGrid);


    return mainLayout;


}



private ToolStrip addToolStrip(){
    ToolStrip gridEditControls = new ToolStrip();
    gridEditControls.setWidth100();
    gridEditControls.setHeight(24);

    //totalsLabel = new Label();
    //totalsLabel.setPadding(5);

    LayoutSpacer spacer = new LayoutSpacer();
    spacer.setWidth("*");

    ToolStripButton newButton = new ToolStripButton();
    newButton.setIcon("[SKIN]/actions/add.png");
    newButton.setTitle("Add  LFM tree node");
    newButton.setPrompt("Add child node to the selected LFM tree node...");
    newButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ListGridRecord parentRecord = treeGrid.getSelectedRecord();
            if (parentRecord == null) return;

            if(parentRecord.getAttribute("level").equals("" +PifsProjectSettings.LFM_LEVEL_ACTIVITY)){
             SC.warn("Can not create children node for Activity! Detail activities are defined in the budget....");
             return;
            }

            Record newRecord = new Record();
            newRecord.setAttribute("project", parentRecord.getAttribute("project"));
            newRecord.setAttribute("project_phase", parentRecord.getAttribute("project_phase"));

            int recordLfmLevel = (new Integer(parentRecord.getAttribute("level"))).intValue() + 1;
            newRecord.setAttribute("level", recordLfmLevel);

            newRecord.setAttribute("name", "...");

            int parentRecordId = (new Integer(parentRecord.getAttribute("id"))).intValue() ;
            newRecord.setAttribute("parent", parentRecordId);

            int recordSublevel =  (new Integer(parentRecord.getAttribute("num_children"))).intValue() + 1;
            newRecord.setAttribute("sublevel", recordSublevel);
            newRecord.setAttribute("num_children", 0);
            parentRecord.setAttribute("num_children", recordSublevel);

            String parentPath = parentRecord.getAttribute("level_path");
            if(parentPath==null || parentPath.equals("")){
                newRecord.setAttribute("level_path", ""+ recordSublevel);
            }else{
                newRecord.setAttribute("level_path", parentPath+"."+recordSublevel);
            }


            treeGrid.addData(newRecord);
            treeGrid.markForRedraw();
            treeGrid.setIsGroup(true);





        }
    });



    ToolStripButton editButton = new ToolStripButton();
    editButton.setIcon("[SKIN]/actions/edit.png");
    editButton.setTitle("Edit LFM tree node");
    editButton.setPrompt("Edit selected LFM tree node...");
    editButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ListGridRecord record = treeGrid.getSelectedRecord();
            if (record == null) return;
            treeGrid.startEditing(treeGrid.getDataAsRecordList().indexOf(record), 1, false);


        }
    });

    ToolStripButton removeButton = new ToolStripButton();
    removeButton.setIcon("[SKIN]/actions/remove.png");
    removeButton.setTitle("Remove LFM tree node");
    removeButton.setTitle("Remove selected LFM tree node...");
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
             ListGridRecord record = treeGrid.getSelectedRecord();
             if (record == null) return;


             String parentId = record.getAttribute("parent");

             if(record.getAttribute("level").equals("" +PifsProjectSettings.LFM_LEVEL_GO)){
                 SC.warn("General objective can not be deleted!");
                 return;
             }

             treeGrid.removeSelectedData();
             treeGrid.markForRedraw();
             treeGrid.setIsGroup(true);



             ListGridRecord[] allRecords = treeGrid.getRecords();
             for(int i=0; i<allRecords.length; i++){
                 if(allRecords[i].getAttribute("id").equals(parentId)){
                     ListGridRecord parentRecord = allRecords[i];
                     int numChildren = (new Integer(parentRecord.getAttribute("num_children"))).intValue();
                     numChildren--;
                     if(numChildren<0){numChildren = 0;}
                     parentRecord.setAttribute("num_children", numChildren);



                     return;

                 }
             }


        }
    });

    gridEditControls.setMembers(newButton, spacer, editButton, removeButton);

    return gridEditControls;


}

1 个答案:

答案 0 :(得分:1)

目前尚不清楚如何实现这一点(上面的代码不会这样做),但为了以防万一,我们添加了一个空检查。

http://smartclient.com/builds尝试下一个每夜3.1d版本(7.7.2012),看看是否能解决您的问题。