2011-06-13 2 views
0

GroupBy 필드이지만 표시되지 않는 제목을 표시하는 데 다른 방법을 시도했습니다. 모든 다른 레코드가 그룹화에서 제대로 표시됩니다.JQuery 템플릿이 groupby로 설정된 레코드를 표시하지 않습니다

누구든지 그 문제를 해결하는 방법을 알려주십시오.

기록은 이제 {제목} 자리를 보여주는하지만 $를 작성하지

{Title} 
     HRDInactive  HRD  
     HRDN1   HR 
     HRBDN   HRB  
     HRBCDN   HRC  
{Title} 
     PatientsCInactive  PatientsC 
     PatientsADN    PatientsA 
     PatientsBDN    PatientsB 

Rsponse Firefox에서 방화범

[[{"ParentMenuId":0,"Id":30,"GroupName":"footer_menu","IndexOrder":0,"Title":"Health Resources","DisplayName":"HRDInactive","UrlName":"HRD","Active":false,"Message":null,"Status":null},{"ParentMenuId":0,"Id":27,"GroupName":"footer_menu","IndexOrder":1,"Title":"Health Resources","DisplayName":"HRDN1","UrlName":"HR","Active":true,"Message":null,"Status":null},{"ParentMenuId":0,"Id":28,"GroupName":"footer_menu","IndexOrder":2,"Title":"Health Resources","DisplayName":"HRBDN","UrlName":"HRB","Active":true,"Message":null,"Status":null},{"ParentMenuId":0,"Id":29,"GroupName":"footer_menu","IndexOrder":3,"Title":"Health Resources","DisplayName":"HRBCDN","UrlName":"HRC","Active":true,"Message":null,"Status":null}],[{"ParentMenuId":0,"Id":26,"GroupName":"footer_menu","IndexOrder":1,"Title":"Patients","DisplayName":"PatientsCInactive","UrlName":"PatientsC","Active":false,"Message":null,"Status":null},{"ParentMenuId":0,"Id":24,"GroupName":"footer_menu","IndexOrder":2,"Title":"Patients","DisplayName":"PatientsADN","UrlName":"PatientsA","Active":true,"Message":null,"Status":null},{"ParentMenuId":0,"Id":25,"GroupName":"footer_menu","IndexOrder":3,"Title":"Patients","DisplayName":"PatientsBDN","UrlName":"PatientsB","Active":true,"Message":null,"Status":null}]] 

AJA을 ahowing 테이블 형식 기록 X 통화

var ReloadGrid = (function(){ 
      $.getJSON("/FooterMenu/GetFooterGrid", function(data) { 
       $('#gridTemplate').tmpl(data).appendTo('table.gridTable > tbody'); 
      }); 
}); 

tmpl 함수 배열을 전달 템플릿

<script id="gridTemplate" type="text/x-jQuery-tmpl"> 
    <tr class="gridRow"> 
     <td class="gridSpan" >${Title}</td> 
    </tr> 
    {{tmpl($data) "#cellTemplate"}} 
</script> 
<script id="cellTemplate" type="text/x-jQuery-tmpl"> 
    <tr class="gridRow"> 
     <td class="cellTd">${DisplayName}</td> 

    </tr> 
</script> 


<div class="gridDiv"> 
<table class="gridTable" cellspacing="0" cellpadding="0"> 
    <tbody> 
     <tr class="gridTitleRow"> 
      <td class="iconLink widthAuto">Display Name</td> 
     </tr> 
    </tbody> 
</table> 
</div> 

답변

1

는, 상기 어레이 내의 각 항목에 대한 템플릿을 실행한다.

무엇 샘플에서 일어나는 것은 gridTemplate 실제로 같은 항목의 배열입니다 가장 바깥 쪽 배열의 각 항목을 부여한다는 것입니다 :

[{"ParentMenuId":0,"Id":30,"GroupName":"footer_menu","IndexOrder":0,"Title":"Health Resources","DisplayName":"HRDInactive","UrlName":"HRD","Active":false,"Message":null,"Status":null},{"ParentMenuId":0,"Id":27,"GroupName":"footer_menu","IndexOrder":1,"Title":"Health Resources","DisplayName":"HRDN1","UrlName":"HR","Active":true,"Message":null,"Status":null},{"ParentMenuId":0,"Id":28,"GroupName":"footer_menu","IndexOrder":2,"Title":"Health Resources","DisplayName":"HRBDN","UrlName":"HRB","Active":true,"Message":null,"Status":null},{"ParentMenuId":0,"Id":29,"GroupName":"footer_menu","IndexOrder":3,"Title":"Health Resources","DisplayName":"HRBCDN","UrlName":"HRC","Active":true,"Message":null,"Status":null}] 그런

, 당신은 $data 통과 cellTemplate에 위의 배열에있는 각 항목의 템플릿을 실행하고 있으므로 실제 데이터를 얻을 수 있습니다. 많이

<td class="gridSpan" >${$data[0].Title}</td> 
+0

완벽한 감사 :

제목이 외부 배열의 각 항목에 동일한 경우

, 그럼 난 당신이 뭔가를 할 수 있다고 가정합니다. – Pirzada

관련 문제