2017-01-29 2 views
1

* 내 게시물을 편집했습니다. 아래 스크립트를 편집하는 데 도움이 필요합니다. 이 스크립트는 인덱스보기 페이지에서 테이블의 요소 필드의 색을 지정하는 데 사용됩니다. 다른 필드의 값이 "출석"인 것처럼 필드 값이 "Schstatus"인 다른 요소 필드의 색을 지정할 수 있어야합니다. "Schstatus"필드의 형식을 정의하려면 무엇을 추가해야합니까?두 개의 자바 스크립트를 함께 사용하십시오.

{(function() { 

    "use strict"; 
    // Run an event when the record list page is displayed 
    kintone.events.on('app.record.index.show', function(event) { 

     //Retrieve an array of field elements of the fields with field code of "Attendance" 
     var elStatus = kintone.app.getFieldElements('Attendance'); 

     //Change the properties of the retrieved field elements for each record 
     for (var i = 0; i < elStatus.length; i++) 
     { 
      var record = event.records[i]; 
      if (record['Attendance']['value'] === "Call Out") 
      { 
       elStatus[i].style.color = 'white'; 
       elStatus[i].style.backgroundColor = "#e74c3c"; 

      } 

      else if (record['Attendance']['value'] === "Pending") 
      { 
       elStatus[i].style.color = 'black'; 
       elStatus[i].style.backgroundColor = "#ffcc00"; 
      } 

      else if (record['Attendance']['value'] === "Confirmed") 
      { 
       elStatus[i].style.color = 'white'; 
       elStatus[i].style.backgroundColor = "#a3b815"; 

      } 

     } 

    }); 
})(); 
} 
+0

your_function_name('Schstatus');를 사용한다. co.kr/watch? v = fju9ii8YsGs) 비디오. 다른 프로그래밍 언어에 익숙하다면 JS에 큰 도움이 될 것입니다. –

답변

0

elStatuss를 함수 매개 변수로 전달하십시오. [본]와 공급 90분 (https://www.youtube - 단 기능 decleration이 라인

function your_function_name(elStatuss) { 

"use strict"; 
// Run an event when the record list page is displayed 
kintone.events.on('app.record.index.show', function(event) { 

    //Retrieve an array of field elements of the fields with field code of one that is given as param. 
    var elStatus = kintone.app.getFieldElements(elStatuss); 

    //Change the properties of the retrieved field elements for each record 
    for (var i = 0; i < elStatus.length; i++) 
    { var record = event.records[i]; 
     if (record['Attendance']['value'] === "No-Show") 

    { elStatus[i].style.color = 'white'; 
     elStatus[i].style.backgroundColor = 'red'; } 


    else if (record['Attendance']['value'] === "Late") 
    { elStatus[i].style.color = "#a023bc";  } 


    else if (record['Attendance']['value'] === "On-Time") 
    { elStatus[i].style.color = 'green';   } 

    } 

}); 

변경 한 var elStatus = kintone.app.getFieldElements(elStatuss);

하고는 your_function_name('Attendance'); 또는도

+0

Karlis에게 감사드립니다. 방금 소리가 덜 혼란스럽게 게시물을 편집했습니다. –

관련 문제