2012-01-04 5 views
2

私はエディタグリッドとカスタムタイプのストアを持っています。エディタグリッドのカスタムタイプストアフィールドが正しくマップされていません

店舗:

var sourceStore = new Ext.data.JsonStore({ 
    url: hp, 
    storeId: 'labels-data-store', 
    idProperty: 'ID', 
    root: 'results', 
    fields: [{ 
     name: 'ID', 
     type: 'int' 
    }, { 
     name: 'LanguageID', 
     type: 'int' 
    }, { 
     name: 'KeyID', 
     type: 'int' 
    }, { 
     name: 'Value', 
     type: 'string' 
    }, { 
     name: 'ToolTip', 
     type: 'string' 
    }, { 
     name: 'LanguageName', 
     type: 'string' 
    }, { 
     name: 'KeyInfo', 
     type: 'LanguageKeyInfo' 
    }, 
    CUSTOM TYPE HERE !! !{ 
     name: 'ServerComments', 
     type: 'string' 
    }] 
}); 

エディタグリッド:

var sourceGrid = new Ext.grid.EditorGridPanel({ 
    id: 'source-grid', 
    region: 'center', 
    title: localize.sourceView, 
    iconCls: 'source-view-title', 
    store: sourceStore, 
    trackMouseOver: true, 
    disableSelection: false, 
    loadMask: true, 
    split: true, 
    stripeRows: true, 
    border: true, 
    autoExpandColumn: 'label', 
    cm: sourceColModel, 

    // customize view config 
    viewConfig: { 
     forceFit: true, 
     enableRowBody: true, 
     showPreview: false, 
     emptyText: localize.noRecordsFound 
    }, 

    sm: new Ext.grid.RowSelectionModel({ 
     singleSelect: false, 
     moveEditorOnEnter: true 
    }) 
}); 

、カスタマーのタイプの実装:

LanguageKeyInfo = function() { 
    this.ID = arguments[0]; 
    this.Value = arguments[1]; 
    this.Description = arguments[2]; 
} 

Ext.data.Types.LANGUAGEKEYINFO = { 
    convert: function (v, data) { 

     if (!data) { 
      return null; 
     } 

     if (!data.KeyInfo) { 
      return null; 
     } 

     return new LanguageKeyInfo(
     data.KeyInfo.ID, 
     data.KeyInfo.Value, 
     data.KeyInfo.Description); 
    }, 

    sortType: function (key) { 
     return key.ID; 
    }, 

    type: 'LanguageKeyInfo' 
} 

ソース列モデル:

var sourceColModel = new Ext.grid.ColumnModel({ 
    columns: [{ 
     header: 'ID', 
     dataIndex: 'ID', 
     width: 50, 
     hidden: true, 
     sortable: true 
    }, { 
     header: 'Language ID', 
     dataIndex: 'LanguageID', 
     width: 50, 
     hidden: true, 
     sortable: true 
    }, { 
     header: 'Language', 
     dataIndex: 'LanguageName', 
     width: 20, 
     hidden: true, 
     sortable: true 
    }, { 
     header: 'Key ID', 
     dataIndex: 'KeyID', 
     width: 30, 
     hidden: true, 
     sortable: true 
    }, { 
     header: 'Key', 
     dataIndex: 'KeyValue', 
     width: 40, 
     sortable: true, 
     editor: new Ext.form.TextField({ 
      allowBlank: false, 
      maxLength: 200 
     }) 
    }, { 
     header: 'Label', 
     dataIndex: 'Value', 
     sortable: true, 
     editor: new Ext.form.TextField({ 
      allowBlank: false, 
      maxLength: 500 
     }), 
     renderer: function (sc) { 
      var lanID = getSelectedLanguageID() ? getSelectedLanguageID() : 1; 
      switch (parseInt(lanID)) { 
       case 2: 
        return '<div class="rtl">' + sc + '</div>'; 
       default: 
        return sc; 
      } 
     } 
    }, { 
     header: 'Description', 
     dataIndex: 'KeyDescription', 
     width: 30, 
     editor: new Ext.form.TextField({ 
      allowBlank: true, 
      vtype: 'englishOnly', 
      maxLength: 100 
     }) 
    }, { 
     header: 'Tool Tip', 
     dataIndex: 'ToolTip', 
     width: 80, 
     sortable: true, 
     editor: new Ext.form.TextField({ 
      allowBlank: true, 
      maxLength: 200 
     }) 
    }] 
}); 

最初の列の行の編集を開始すると、テキストフィールド値は[オブジェクト、オブジェクト]です。これは、グリッドがKeyInfoオブジェクトをテキストボックス値に渡していることを意味します。

KeyInfoプロパティの1つをテキストボックスに送信し、それをストアレコードにマップするにはどうすればよいですか? dataIndex: 'KeyValue',はおそらくdataIndex: 'KeyInfo', は、第二に、私は、グリッドエディタのカスタムタイプに対するサポートがあるとは思わないようになります。

+0

カスタムタイプフィールドの列モデル定義を表示できますか? – dbrin

答えて

0

手始めに、あなたのdataIndexは、有効なレコードのマッピングを参照していません。もちろん私は間違っているかもしれない。

+0

あなたはdataIndexについて正しいです。カスタムタイプのグリッドサポートに関する情報が見つかりませんでした。被写体に光を当てることができればいいですね。あなたのリプレイに感謝します。 – AMember

関連する問題