easyUI dategrid field 는 formatter 로 하위 속성 을 표시 합 니 다.
<body class="easyui-layout" data-options="fit:true,border:false">
<table id="dg" class="easyui-datagrid" data-options="fit:true,border:false"
url="book/listBookForUser"
toolbar="#toolbar" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true">
<thead>
<tr>
<th field="bookId" width="50"> ID</th>
<th field="bookName" width="50"> </th>
<th field="bookType" width="50" formatter="formatBookType"> </th>
<th field="author" width="50"> </th>
<th field="callNumber" width="50"> </th>
<th field="iSBN" width="50">ISBN</th>
<th field="publisher" width="50"> </th>
<th field="publishYear" width="50"> </th>
<th field="series" width="50"> </th>
<th field="language" width="50"> </th>
<th field="price" width="50"> </th>
<th field="page" width="50"> </th>
</tr>
</thead>
</table>
여기 서 북 타 입 과 북 타 입 은 다 대 일 관계 입 니 다. 배경 에서 돌아 오 는 제 이 슨 에서 북 타 입 은 제 이 슨 대상 입 니 다. 북 타 입의 북 타 입 Name 을 얻 으 려 면 북 타 입. 북 타 입 Name 을 직접 사용 할 수 없습니다. 그래서 field 의 북 타 입 필드 에 formatter 를 추가 합 니 다.
function formatBookType(val,row,index){
//alert(row.bookType);
if(val==null){
return "";
}else
return row.bookType.bookTypeName;
}
val 은 이 필드 의 값, 즉 bookType 입 니 다.row 는 줄 값 입 니 다.여기에 if 를 빈 판단 으로 추가 해 야 합 니 다. 제 가 가지 고 있 는 책 은 유형 을 설정 하지 않 았 기 때문에 유형 명 을 찾 지 못 해서 전체 date 에 데 이 터 를 표시 하지 않 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
EasyUI 생성 트리, 탭 열기 클릭텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.