Avatar

Question About setFieldShown

Afief

Dear Developers

It's on Detail, after you click on a detail of record on index

I was able to hide a Field simply by typing

kintone.app.record.setFieldShown("field_name", false);

However, after I set two field into a table, I'm able to hide the table but can't hide the field (row)

Let's say: table=table_ab, field 1=A, field 2=B

I'm able to hide the table_ab, but cant hide A using kintone.app.record.setFieldShown("A", false);

Please help, any answer would be appreciated, thank you

Follow 3 followers
1

3 comments

Avatar
Yuzo Arai 1 vote

Hello Afief,
This can be done by using the JS and the CSS. The scripts are something like the following:

Javascript

(function() {
"use strict";
kintone.events.on(["app.record.detail.show"], function(event) {
document.getElementById('record-gaia').classList.add('xxx-show');
return event;
});
})();

CSS:

.xxx-show .subtable-gaia th:nth-child(2),
.xxx-show .subtable-gaia td:nth-child(2) {
display: none;
}

The above sample scripts will hide the 2nd field in a table upon displaying the record detail.
If you want to hide the 3rd field in a table, change the "nth-child(2)" to "nth-child(3)" in the CSS script.
Also FYI, you need to create separate files for the Javascript and the CSS.

And lastly, these scripts are utilizing the DOM so it may not work one day after any kintone update when the DOM structure changes.

I hope this helps.

1
Comment actions Permalink
Avatar
William Sayama 0 votes

Just to note, kintone.app.record.setFieldShown() cannot be used against fields inside tables

0
Comment actions Permalink
Avatar
Afief 1 vote

Hello Yuzo and William

The problem has been fixed, I found the solution based on what you posted here, thank you very much, I appreciate it

1
Comment actions Permalink