You can check all by pressing the CheckON button.
First,Display only Ethan
Only Ethan was displayed.
press the CheckON button please.
Only Ethan was checked.
Next, Let's remove the check.
press the CheckOFF button to remove the check.
unchecked all
JavaScript
(function() {
'use strict';
const getquery = function() {
const appNo = kintone.app.getId()
const OnBtnUpdate = document.createElement('button');
OnBtnUpdate.innerText = 'CheckON';
OnBtnUpdate.id = 'ONDateButton';
const OFFBtnUpdate = document.createElement('button');
OFFBtnUpdate.innerText = 'CheckOFF';
OFFBtnUpdate.id = 'OFFDateButton';
// ボタン増殖防止
if (document.getElementById('ONDateButton') !== null) {
return;
}
// ボタン増殖防止
if (document.getElementById('OFFDateButton') !== null) {
return;
}
// 絞り込み条件取得
const queryCondition = kintone.app.getQueryCondition();
// ONボタンクリック後の処理
OnBtnUpdate.onclick = function() {
const client = new KintoneRestAPIClient();
const getnoparams = {
app: appNo,
query: '' + queryCondition + '',
fields: ['$id', 'checkBox']
};
const checkOnRecords = [];
client.record.getAllRecordsWithCursor(getnoparams).then((resp) => {
// レコードの数でループ
for (let i = 0; i < resp.length; i++) {
checkOnRecords[i] = {
'id': resp[i].$id.value,
'record': {
'checkBox': {
'value': ['checked']
}
}
};
}
const putrecords = {
app: appNo,
records: checkOnRecords
};
client.record.updateAllRecords(putrecords).then(() => {
alert('Put a check mark ');
location.reload();
}).catch((error) => {
alert('miss');
});
});
};
// OFFボタンクリック後の処理
OFFBtnUpdate.onclick = function() {
const client = new KintoneRestAPIClient();
const getnoparams = {
app: appNo,
query: '' + queryCondition + '',
fields: ['$id', 'checkBox']
};
const checkOffRecords = [];
client.record.getAllRecordsWithCursor(getnoparams).then((resp) => {
// レコードの数でループ
for (let i = 0; i < resp.length; i++) {
checkOffRecords[i] = {
'id': resp[i].$id.value,
'record': {
'checkBox': {
'value': []
}
}
};
}
const putrecords = {
app: appNo,
records: checkOffRecords
};
client.record.updateAllRecords(putrecords).then((resp2) => {
alert('uncheck all');
location.reload();
}).catch((error) => {
alert('miss');
});
});
};
// ボタン設置
kintone.app.getHeaderMenuSpaceElement().appendChild(OnBtnUpdate);
kintone.app.getHeaderMenuSpaceElement().appendChild(OFFBtnUpdate);
}
const eventlist = [
'app.record.index.show'
];
kintone.events.on(eventlist, getquery);