1

私は sencha touch を使用したモバイル アプリケーションのプロジェクトで働いていますが、情報を取得するモデルに問題があります。モデルと json ファイルの内容をお見せします

jsonファイル:(テストするだけで非常に簡単になり、ジオメトリラインを削除しました)

{
        "type": "FeatureCollection",
        "features": [
            {
            "properties": {"graphic": "img/restaurant.png","Name": "Igor Tihonov", "Country":"Sweden", "City":"Gothenburg"}
            }

        ]
}

私のモデル:

 Ext.regModel('Features', {
        hasMany: {model: 'Properties', name: 'properties'}

    });


    Ext.regModel('Properties', {
        fields: ['graphic', 'Name', 'Country', 'City'],
        associations: [
            {type: 'belongsTo', model: 'Features'}
        ]
    });

店 :

 Ext.data.Store({
        model: 'Features',
        proxy: {
            type: 'ajax',
            url : 'poi2.json',
            reader: {
                type: 'json',
                rootProperty: 'features'
            }
        },
        autoLoad:true
    });

ブロックされてから1週間以上経ちました。助けていただければ幸いです。ありがとうございました

4

1 に答える 1

0

「type」プロパティを使用していない場合は、次のことをお勧めします。

  • 最初のモデルとすべての関連付けを失う
  • ストアのモデルを「Properties」に設定します (rootProperty が「features」に設定されているため、これは機能します)。
  • JSON を変更して、プロパティが JSON のさらに深いレベルにならないようにします。

    {  
        "type": "FeatureCollection",  
        "features": [  
            {  
                "graphic": "img/restaurant.png",  
                    "Name": "Igor Tihonov",   
                "Country":"Sweden",  
                "City":"Gothenburg"}  
            },  
            {  
                "graphic": "img/restaurant2.png",  
                "Name": "Igor Tihonov2",   
                "Country":"Sweden",  
                "City":"Gothenburg"}    
            }  
        ]  
    }  
    

[編集]
json 形式を維持するには、次のアプローチを使用します。

  • rootproperty を「features」に設定します
  • 「hasMany」関連付けのみを含む「機能」モデルをプロパティ モデル (実際のフィールドを含む) に追加します。
  • ストアのモデルを機能モデルに設定します

[/編集]

于 2012-10-18T00:08:48.517 に答える