2010-05-27 2 views
0

I 다음 JS 있습니다의 ExtJS DataView를 ArrayStore 문제

http://monobin.com/__m1c171c4e

다음 코드를 :

코드 :

그래서 고해상도의 아이 배열에 DataView를 결합
var tpl = new Ext.XTemplate(
    '<tpl for=".">', 
     '<div class="thumb-wrap" id="{Name}">', 
     '<div class="thumb"><img src="{ImageMedium}" title="{Name}"></div>', 
     '<span class="x-editable">{Name}</span></div>', 
    '</tpl>', 
    '<div class="x-clear"></div>' 
); 

var store = new Ext.data.ArrayStore({ 
    fields: [{ name: 'name' }, { name: 'ImageMedium'}], 
    data: res.data.SimilarArtists 
}); 

var panel = new Ext.Panel({ 
    frame: true, 
    width: 535, 
    autoHeight: true, 
    collapsible: true, 
    layout: 'fit', 
    title: 'Simple DataView (0 items selected)', 
    items: new Ext.DataView({ 
     store: store, 
     tpl: tpl, 
     autoHeight: true, 
     multiSelect: true, 
     overClass: 'x-view-over', 
     itemSelector: 'div.thumb-wrap', 
     emptyText: 'No images to display', 
     prepareData: function (data) { 
      data.Name = Ext.util.Format.ellipsis(data.Name, 15); 
      return data; 
     }, 

     plugins: [ 
      new Ext.DataView.DragSelector(), 
      new Ext.DataView.LabelEditor({ dataIndex: 'name' }) 
     ], 

     listeners: { 
      selectionchange: { 
       fn: function (dv, nodes) { 

       } 
      } 
     } 
    }) 
}); 

.data.SimilarArtists

아무 것도 볼 수 없습니다. ms?

prepareData도 호출되지 않습니다?

내가 뭘 잘못하고 있니?

w : //

답변

2

데이터 구조는 배열 데이터가 아닌 JSON입니다. 대신 JsonStore으로 전환 해보세요. JsonStore는 JsonReader 및 HttpProxy (원격 데이터 소스)로 사전 구성되며 URL에서 데이터를로드하기위한 것입니다. 로컬 데이터에서 JSON을로드해야하는 경우 JsonReader 및 MemoryProxy를 사용하여 일반 상점을 만들어야합니다.

+0

건배 dude - 하나처럼 들리 네. 나는 나중에 시험해 볼 것이다. 그러나 나는 이것이 작동 할 것이다라는 것을 알고있다 - 지난 밤에 우스운 이야기 5를 보내고 있었다 : s – iwayneo