2012-08-06 2 views
1

struts2-jquery-grid에 대한 쇼케이스를 확인하고있었습니다. 내 개체의 목록을 그리드 모델로 보내는 방법을 이해할 수 있지만 예제에서는 개체가 단순하지만 개체로 특성이 없습니다. 그러나 내 경우에는, 내 모델 클래스는 다음과 같습니다 : 샘플에서다 대일 매핑 및 Struts2-jquery-grid

public class Student(
private String first_name; 
private String last_name; 
private Person father; 
private Person mother; // an attribute of another class 

// other attributes, getters and setters 

} 

, 그들은 다음과 같이 있습니다

<s:url id="remoteurl" action="jsontable"/> 
    <sjg:grid 
     id="gridtable" 
     caption="Customers Examples" 
     dataType="json" 
     href="%{remoteurl}" 
     pager="true" 
     gridModel="gridModel" 
     rowList="10,15,20" 
     rowNum="15" 
     rownumbers="true" 
     resizable="true" 
     resizableAnimate="true" 
     resizableGhost="true" 
     resizableHandles="all" 
    > 
     <sjg:gridColumn name="id" index="id" title="ID" width="30" formatter="integer" sortable="false"/> 
     <sjg:gridColumn name="name" index="name" title="Name" width="250" sortable="true"/> 
     <sjg:gridColumn name="country" index="country" title="Country" sortable="false"/> 
     <sjg:gridColumn name="city" index="city" title="City" sortable="false"/> 
     <sjg:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" align="right" formatter="currency" sortable="false"/> 
    </sjg:grid> 
    </div> 

하세요, 아버지와의 ID를 표시하는 방법에 대한 어떤 생각 어머니 (내 데이터베이스의 외래 키)? 또한, 모든 속성을 언급하지 않을 수 있습니까 ?? 정말 고마워.

+0

struts2-json-plugin, 특히 _include_ 및 _exclude_ 매개 변수의 사용 예를 찾으십시오. DB에서 필요한 것 이상을 되 찾는 데는 비용이 많이들 수 있기 때문에 필요한 것에 가까이 가져 가야합니다. 서비스 계층은 검색 할 수있는 대상을 지정해야합니다. 이와 같이 두 가지 이슈가 있습니다 : 1) db로부터 필요한 것을 어떻게 얻고 그것을 표현할 것인가 (db 계층과 결합 된 서비스 계층)와 2) 그 데이터의 표현 (struts2 json 결과 사용). jQuery 커뮤니티의 도움을 줄여 세부 정보를 숨기기 때문에 struts2 jquery 태그를 싫어합니다. – Quaternion

답변

0

내가 옳다고 생각하면 father 속성의 Id과 의 mother 속성을 표시하려고합니다. 즉 Person 개체의 속성은 Id입니다. 이것이 맞으면 이것을 할 수 있습니다.

<sjg:gridColumn name="father.id" index="father.id" title="Father Id" width="250" sortable="true"/> 
<sjg:gridColumn name="mother.id" index="mother.id" title="Mother Id" width="250" sortable="true"/> 

나는 이것이 당신의 문제를 해결할 것이라고 생각합니다.

관련 문제