Skill/html js css

[js] table의 td에 값setting

진열사랑 2024. 2. 7. 09:30

/**----------------------------------------------------------
* Function Name : fnInitDivTbl
* Description : td 항목 값 초기화
* Author : payletter, 2019. 02. 21.
* Modify History : Just Created.
------------------------------------------------------------*/
fnInitDivTbl: function(divId) {
$("#{0} table tr td:not('.td-item')".format(divId)).html("");
},

/**------------------------------------------------------------
* Function Name : fnDivTblSettings
* Description : td 항목 값 자동 Mapping
* Author : payletter, 2019. 02. 21.
* Modify History : Just Created.
------------------------------------------------------------*/
fnDivTblSettings: function(divId, obj) {
for (var key in obj) {
var value = obj[key];
value = COMMON.Utils.fnIsEmpty(value) ? "-" : ($.isNumeric(value)) ? COMMON.Utils.fnAddComma(value) : value;
var target = "#{0} table tr td[td-id='td_{1}']".format(divId, key);

// 해당 태그에 html 셋팅
if($(target).length == 1) {
switch (key) {
default:
COMMON.Utils.fnIsEmpty(value) ? $(target).html("") : $(target).html(value);
break;
}
}
}
},