2017-09-08 2 views
5

저는 NS에 익숙하지 않고 라이딩 목록 안에 승객 명단을 표시하려고합니다. 각 승차자마다 승객이 많습니다.NativeScript - listview의 배열

그래서 전 세계 listview (라이드) 안에 listview (승객)를 넣으려고했는데, 라이드는 listview가 작동하지만 승객은 (분명히) 그렇지는 않습니다. 올바른 방법이라고 생각하지 않습니다.

rides.xml :

<ListView items="{{ ridesList }}" id="ridesList"> 
    <ListView.itemTemplate> 
    <!-- Rides --> 
    <StackLayout class="box" orientation="vertical"> 
     <GridLayout class="boxHeader" rows="auto" columns="*"> 
     <Label class="title" verticalAlignment="center" horizontalAlignment="left" text="{{reference}}" /> 
     </GridLayout> 
     <StackLayout class="boxContent" orientation="vertical"> 
     <GridLayout class="checkpoints" rows="auto, auto" columns="80, *, 60"> 
      <!-- --> 
      <ListView items="{{ passagers }}" id="passagersList"> 
      <ListView.itemTemplate> 
       <StackLayout class="timedate" orientation="vertical" row="0" col="0"> 
        <Label class="time" text="14:32" /> 
        <Label class="firstname" text="{{firstname}}" /> 
       </StackLayout> 
       [...] 
       </ListView.itemTemplate> 
      </ListView> 
     </GridLayout> 
     </StackLayout> 
    </StackLayout> 
    <!-- /Rides --> 
    </ListView.itemTemplate> 
</ListView> 

rides.js

var ride = new RideViewModel([]); 
[...] 
exports.loaded = function(args) { 
    var page = args.object; 
     page.bindingContext = ride; 

      ride.futurCourse().then(function(data) { 
           [...] 

           ride.fillFuturCourse(data); 
      }); 
}; 

를 타고 - 뷰 - model.js

viewModel.fillFuturCourse = function(data){ 

    var testdModel = new ObservableArray(); 
    var jsone = JSON.parse('{"course":[{"id":"5","reference":"test","passagers":[{"firstname":"julien"},{"firstname":"andre"}]},{"id":"6","reference":"RF7878788"}]}'); 
    testdModel= jsone.course; 
    viewModel.set("ridesList",testdModel); 
}; 

감사

여기 내 코드입니다!

답변

1

그래서 내가 리피터 후 글로벌 레이아웃을 포함 (여기 GridLayout과)를 잊지 않고, 솔루션, repeater를 사용 발견

rides.xml :

<ListView items="{{ ridesList }}" id="ridesList"> 
    <ListView.itemTemplate> 
    <!-- Rides --> 
    <StackLayout class="box" orientation="vertical"> 
     <GridLayout class="boxHeader" rows="auto" columns="*"> 
     <Label class="title" verticalAlignment="center" horizontalAlignment="left" text="{{reference}}" /> 
     </GridLayout> 
     <StackLayout class="boxContent" orientation="vertical"> 
     <GridLayout class="checkpoints" rows="auto, auto" columns="80, *, 60"> 
      <!-- --> 
     <Repeater items="{{ passagers }}"> 
      <Repeater.itemTemplate> 
       <GridLayout class="checkpoints" rows="auto, auto" columns="80, *, 60"> 
         <StackLayout class="timedate" orientation="vertical" row="0" col="0"> 
          <Label class="time" text="14:32" /> 
          <Label class="firstname" text="{{firstname}}" /> 
          </StackLayout> 
          [...] 
       </GridLayout> 
      </Repeater.itemTemplate> 
     </Repeater> 
     </GridLayout> 
     </StackLayout> 
    </StackLayout> 
    <!-- /Rides --> 
    </ListView.itemTemplate> 
</ListView>