remove trash icon from date field in DV

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bebbit
Posts: 4
Joined: 2020-07-21 18:15

remove trash icon from date field in DV

Post by bebbit » 2023-08-23 11:17

Hi,

I have a detail view screen for a table holding date fields.
Each field is accompanied by two icons: a trash icon and a calendar icon.
I would like to remove the trash icon because the dates are mandatory.

Does anyone have a clue to accomplish that?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: remove trash icon from date field in DV

Post by jsetzer » 2023-08-23 12:13

You are right, default date picker (combination of three <select/>-boxes) shows date-clear-button, even if the field is required.

In many situations this makes sense to me, because it is faster to click that button instead of selecting empty option three times.

Anyway, you can use the following Javascript code for hiding the date-clear-button:

Before
chrome_E5e4ma8cdW.png
chrome_E5e4ma8cdW.png (2.03 KiB) Viewed 6225 times

Javascript Code

Code: Select all

// file: hooks/TABLENAME-dv.js
const fieldname = "date_till";

hideDateClearButton(fieldname);

function hideDateClearButton(fieldname) {
    jQuery(`.fd-date-clearer[data-for='${fieldname}']`).hide();
}
After
j4bhb7KR4m.png
j4bhb7KR4m.png (1.88 KiB) Viewed 6225 times
---

PS: Just in case someone also wants to hide the Calendar-button:

Code: Select all

// file: hooks/TABLENAME-dv.js
const fieldname = "date_till";

hideDateClearButton(fieldname);
hideDateSelectButton(fieldname);

function hideDateClearButton(fieldname) {
    jQuery(`.fd-date-clearer[data-for='${fieldname}']`).hide();
}

function hideDateSelectButton(fieldname) {
    jQuery(`#fd-but-${fieldname}`).hide();
}
gxM2LF8HEA.png
gxM2LF8HEA.png (1.69 KiB) Viewed 6225 times
---

PPS: In case you want to hide all date-clear-buttons in a DV at once, you can use this:

Code: Select all

// file: hooks/TABLENAME-dv.js
hideAllDateClearButtons();

function hideAllDateClearButtons() {
    jQuery(`.fd-date-clearer[data-for]`).hide();
}

Hope this helps.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

bebbit
Posts: 4
Joined: 2020-07-21 18:15

Re: remove trash icon from date field in DV

Post by bebbit » 2023-08-24 07:32

Thanks for the reply.

Unfortunately it does not work.

This is what I added in the file ARCHIEFSTUK-dv.js:
// file: hooks/ARCHIEFSTUK-dv.js

const fieldname = "date_till";

hideDateClearButton(fieldname);

function hideDateClearButton(fieldname) {
jQuery(`.fd-date-clearer[data-for='${fieldname}']`).hide();
}


Any suggestion?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: remove trash icon from date field in DV

Post by jsetzer » 2023-08-24 12:46

const fieldname = "date_till";
Are you sure your specific field has the same name date_till as my sample field?

Are there any red errors in console?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

bebbit
Posts: 4
Joined: 2020-07-21 18:15

Re: remove trash icon from date field in DV

Post by bebbit » 2023-08-24 16:00

Changed fieldname to my actual fieldname "DatumArchiefstuk", but that didn't help.

Tried your clear all option. Doesn't work either.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: remove trash icon from date field in DV

Post by jsetzer » 2023-08-24 16:49

I cannot see your code, so I cannot help debugging.

It works here if put into the correct file in hooks directory with correct fieldname after reload without cache.
Are there any red errors in console?
Did you check that?

And are you using an up-to-date version?

Is it really a date field or something different, for example datetime?

We need more information!
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

bebbit
Posts: 4
Joined: 2020-07-21 18:15

Re: remove trash icon from date field in DV

Post by bebbit » 2023-08-25 07:32

created a page with some pictures.
hope that helps.
Image
Image
Image

Post Reply