2

ツリー列プラグインを使用する dgrid があります。ユーザーがツリーをクリックするたびに、サーバーを呼び出し、サブ行 (json) をキャッチしてバインドします。しかし、それが起こると、下の画像のように、これらの下位行が間違った位置に表示されます。最も奇妙なのは、ページネーションを変更すると、最初のページに戻った後、サブ行が正しい場所にとどまることです。

(私の英語を理解できるかどうか教えてください。そうすれば、テキストを改善することができます)

サブローの位置が間違っている dgrid

私のdgridコード:

  var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]);

    var grid = new CustomGrid({
        columns: [
            selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"),
            {label:'Id', field:'id', sortable: false},
            tree({label: "Title", field:"title", sortable: true, indentWidth:20, allowDuplicates:true}),
            //{label:'Title', field:'title', sortable: false},
            {label:'Count', field:'count', sortable: false}
        ],
        store: this.memoryStore,
        collapseOnRefresh:true,
        pagingLinks: false,
        pagingTextBox: true,
        firstLastArrows: true,
        pageSizeOptions: [10, 15, 25],
        selectionMode: "single", // for Selection; only select a single row at a time
        cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
    }, "grid");

私の思い出の店:

loadMemoryStore: function(items){

            this.memoryStore = Observable(new Memory({
                data: items,
                getChildren: function(parent, options){
                    return this.query({parent: parent.id}, options);
                },
                mayHaveChildren: function(parent){
                    return (parent.count != 0) && (parent.type != 'DOC');
                }

            }));

        },

この瞬間、サブ行をバインドしています:

        success: function(data){

            for(var i=0; i<data.report.length; i++){
                this.memoryStore.put({id:data.report[i].id, title:data.report[i].created, type:'DOC', parent:this.designId});
            }

        },

サブ行をバインドするたびに、グリッドの更新のようにできるのではないかと考えていました。ページネーションも同じことをしていると思います。

ありがとう。

編集:

質問を忘れました。さて、どうすればこのバグを修正できますか? dgrid の更新が機能する場合。どうすればいいですか?私が考えていた他のこと、多分私のgetChildrenが間違っているかもしれませんが、私はそれを特定できませんでした.

再度、感謝します。

4

1 に答える 1

3

私の解決策は、親階層から子階層への変更でした。今は正常に動作します。

私のdgridコード:

this.mapReportItems(reportDAO.get()); 
            //this.mapReportItems(x); 
            this.loadMemoryStore(this.reportItems); 

            var CustomGrid = declare([OnDemandGrid, Keyboard, Selection, Pagination]); 

            var grid = new CustomGrid({ 
                columns: [ 
                    selector({label: "#", disabled: function(object){ return object.type == 'DOCx'; }}, "radio"), 
                    {label:'Id', field:'id', sortable: false}, 
                    tree({label: "Title", field:"title", sortable: false, indentWidth:20, shouldExpand:function() { return 0; }}), 
                    //{label:'Title', field:'title', sortable: false}, 
                    {label:'Count', field:'count', sortable: true} 
                ], 
                query: {parent: parent.children }, 
                store: this.memoryStore, 
                deselectOnRefresh: false, 
                //columnReordering:true, 
                collapseOnRefresh:false, 
                pagingLinks: false, 
                pagingTextBox: true, 
                firstLastArrows: true, 
                pageSizeOptions: [10, 15, 25], 
                selectionMode: "single", // for Selection; only select a single row at a time 
                cellNavigation: false // for Keyboard; allow only row-level keyboard navigation 
            }, "grid"); 

私の思い出の店:

this.memoryStore = Observable(new Memory({ data: items, getChildren: function(parent){

            return parent.children; 
        }, 

        mayHaveChildren: function(parent){ 
            //return (parent.count != 0) && (parent.type != 'DOC'); 
            return (parent.children && parent.children.length) || (parent.count != 0 && parent.type != 'DOC'); 
        } 

    }));

この瞬間、サブ行をバインドしています:

success: function(data){ 

                    var node = this.memoryStore.get(this.designId); 

                    for(var i=0; i<data.report.length; i++){ 
                        node.children.push({id:data.report[i].id, title:data.report[i].created, type:'DOC'}); 
                    } 

                    this.memoryStore.put(node); 
                    this.data = data; 
                }, 

追加情報。私の場合、次のように Json データをマップする必要があります。

   this.reportItems = dojo.map(jsondata.reportDesign, function(report) {
                return {
                    //'@uri': report[1],
                    id : report.id,
                    title : report.title,
                    count : report.count,
                    children: [],//report.children,
                    type : report.type
                    //parent : report.parent
                };
            });

このリンクは私にとって役に立ちました: https://github.com/SitePen/dgrid/issues/346

于 2012-11-22T14:52:50.940 に答える