반응형
아래 소스 코드는 jqGrid 테이블 헤더 셀에 배경색을 지정하여 표시하고 있습니다. 각 열 header의 ID를 지정하여 스타일을 개별적으로도 지정할 수 있습니다.
각각의 열에 대해서 스타일을 지정함으로써 헤더와 데이터를 쉽게 식별할 수 있습니다.
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/redmond/jquery-ui.css" type="text/css" />
<!-- jqGrid CSS -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/jqgrid/4.6.0/css/ui.jqgrid.css" type="text/css" />
<!-- The actual JQuery code -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.min.js" /></script>
<!-- The JQuery UI code -->
<script type="text/javascript" src="https://code.jquery.com/ui/1.10.3/jquery-ui.min.js" /></script>
<!-- The jqGrid language file code-->
<script type="text/javascript" src="//cdn.jsdelivr.net/jqgrid/4.6.0/i18n/grid.locale-kr.js" /></script>
<!-- The atual jqGrid code -->
<script type="text/javascript" src="//cdn.jsdelivr.net/jqgrid/4.6.0/jquery.jqGrid.src.js" /></script>
<style>
.ui-jqgrid .ui-jqgrid-htable #list_rn,
.ui-jqgrid .ui-jqgrid-htable #list_cb,
.ui-jqgrid .ui-jqgrid-htable #list_date,
.ui-jqgrid .ui-jqgrid-htable #list_name {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#FF9966), to(#FF9966));
background-image: -webkit-linear-gradient(top, #FF9966 0, #FF9966 100%);
}
.ui-jqgrid .ui-jqgrid-htable #list_id,
.ui-jqgrid .ui-jqgrid-htable #list_product,
.ui-jqgrid .ui-jqgrid-htable #list_amount,
.ui-jqgrid .ui-jqgrid-htable #list_total {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#CC99FF), to(#CC99FF));
background-image: -webkit-linear-gradient(top, #CC99FF 0, #CC99FF 100%);
}
[aria-describedby="list_rn"] {
color: red !important;
}
</style>
<script>
$(document).ready(function() {
var mydata = [
{date:"2007-10-01",name:"test",id:"id",product:"상품1",amount:"10.00",total:"210.00"},
{date:"2007-10-02",name:"test2",id:"id2",product:"상품1",amount:"20.00",total:"320.00"},
{date:"2007-09-01",name:"test3",id:"id3",product:"상품1",amount:"30.00",total:"430.00"}
];
$("#list").jqGrid({
datatype: "local",
data: mydata,
colNames:['날짜', '이름', '아이디','상품','가격','합계'],
colModel:[
{name:'date', index:'date', width:90, align: "center"},
{name:'name', index:'name', width:100 , align: "center" },
{name:'id', index:'id', width:150, align: "center" ,sortable:false },
{name:'product', index:'product', width:80, align: "center"},
{name:'amount', index:'amount', width:80, align: "center"},
{name:'total', index:'total', width:80, align: "center"}
],
autowidth: true,
rownumbers : true,
multiselect:true,
pager:'#pager',
rowNum: 10,
rowList: [10, 20, 50],
sortname: 'id',
sortorder: 'asc',
height: 250,
});
$(window).on('resize.jqGrid', function() {
$("#list").jqGrid('setGridWidth', $("#list").parent().parent().parent().parent().parent().width());
})
$(".jarviswidget-fullscreen-btn").click(function(){
setTimeout(function() {
$("#list").jqGrid('setGridWidth', $("#list").parent().parent().parent().parent().parent().width());
}, 100);
});
});
</script>
<table id="list"></table>
<div id="pager"></div>
반응형
'개발이야기 > jQuery' 카테고리의 다른 글
[jQuery] beforeunload 이벤트로 페이지 이탈 확인하기 (0) | 2023.09.19 |
---|---|
[jQuery] load() 메서드 사용법, 예제, 데이터 전달 (페이지 로드) (0) | 2023.09.18 |
[jQuery] 영문, 숫자, 한글, 특수문자 정규식 입력 체크 (영문 숫자만, 한글만, 영문 숫자 특수문자 조합) (1) | 2023.08.21 |
[jQuery] input focus event 사용 예제 (스타일 변경, focus 이동, focus element) (0) | 2023.08.21 |
[jQuery] UI Sortable 사용하기 (드래그 앤 드롭, 순서변경, 리스트 이동 정렬) (0) | 2023.08.16 |
댓글