2017-01-29 30 views
1

*編集しました。私は以下のスクリプトを編集するのに助けが必要です。このスクリプトは、索引ビュー・ページの表の要素フィールドの色を指定するために使用されます。私は他のフィールドが "出席"の値を持っているように、 "Schstatus"のフィールド値を持つ別の要素フィールドを色付けする必要があります。 "Schstatus"フィールドの書式を定義するために追加する必要があるのは何ですか?2つのJavascriptをまとめて組み合わせる

{(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');を使用しています。 com/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に感謝します。私はちょっと混乱しないようにポストを編集しました。 –

関連する問題