[jQuery] SlickGrid 에서 각 행을 루프돌면서 상태에 따른 색상 세팅하기
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
SlickGrid 에서 각 행을 루프돌면서 상태에 따른 색상 세팅하기
SlickGrid: How to loop through each row and set color based on the condition?
Assuming you're using Slick.Data.DataView
, you can modify the getItemMetadata
method to dynamically add classes to the containing row element. I am going to write this as if your Slick.Data.DataView
instance is called dataView
, here you go:
dataView.getItemMetadata = metadata(dataView.getItemMetadata);
function metadata(old_metadata_provider) {
return function(row) {
var item = this.getItem(row);
var ret = (old_metadata_provider(row) || {});
if (item) {
ret.cssClasses = (ret.cssClasses || '');
if (item.age >= 20 && item.age <= 40) {
ret.cssClasses += ' blue';
} else {
ret.cssClasses += ' red';
}
}
return ret;
}
}
This will add a class of 'blue'
or 'red'
to the row's element.
http://stackoverflow.com/questions/19496846/slickgrid-how-to-loop-through-each-row-and-set-color-based-on-the-condition
'Web > javascript / jQuery' 카테고리의 다른 글
[js] ]innerHTML로 <script> 넣기 (2) | 2015.04.16 |
---|---|
[js] 정규식 표현법 (2) | 2015.04.16 |
TypeError: 'undefined' is not a function (evaluating '$(document)') (130) | 2015.04.13 |
[펌] 자바스크립트 문자열 다루기 (6) | 2015.04.13 |
jQuery에서 특정 라디오버튼만 동적 체크 (4) | 2015.04.13 |