태그
#JQGRID
jqGrid 특정 열값 css 바꾸기
2021년 11월 2일 17:38

이거는 적용 범위가 넓어서 알아두면 좋을 것 같다
스타일뿐만 아니라 함수를 실행시키는 것이기 때문에 유용하닷!!!
편의상 스크립트 부분만 올리겠당
<script>
// 작성자가 이름이 홍채민일 때 글자색 바꾸기
$(function() {
$('#jqGrid').jqGrid({
url : "/board/selectBoardList.do",
mtype : "POST",
datatype : "json",
colNames : ['seq', '번호', '제목', '작성자', '작성일'],
conModeal : [
{name : 'boardSeq', index : 'BOARD_SEQ', align : 'center', hidden : true},
{name : 'num', index : 'NUM', align : 'center', width : '25%'},
{name : 'title', index : 'TITLE', align : 'center', width : '25%'},
{name : 'reg_id', index : 'REG_ID', align : 'center', width : '25%', formatter : chk_reg_id}, // formatter : 함수 실행
{name : 'reg_dt', index : 'REG_DT', align : 'center', width : '25%'},
],
pager : $('#jqGridPager'),
rowNum : 10,
rowList : [10, 20, 30],
autowidth : true
});
function chk_reg_id(cellvalue, options, rowObject) {
var fontStyle = "";
if (cellvalue == "홍채민") {
fontStyle = "style = 'color : red'";
}
return "<p " + fontStyle + ">" + cellvalue + "</p>";
};
});
</script>
참고 사이트는 http://1004lucifer.blogspot.com/2019/04/jqgrid-formatter_21.html 이쪽이다
jqGrid는 이분걸 많이 참고하게 되는것같다
정리도 깔끔하게 되어있음!