Hide empty fields in list

kit-fabrik

New Member
Hello,

I want to hide fields in list when they are empty (nothings is filled in). I think it's quiet easy but I don't know how it works...

Can somebody help me? :)

Thank You!

Regards
 
What do you mean by "hide [...] when they are empty"?

Do you mean if none of the fields in an entire column for a given element have a value, you want to hide the entire column?

There is no built in way of doing this, it would require some PHP scripting in the list template.

-- hugh
 
When viewing in tab-view I want to hide the empty fields an their labels. Additionally I would also hide the whole tab if any field of the regarding category is empty
 
Do you mean list view or details view?
In details view empty elements have a CSS class "fabrikDataEmpty", so you can add a {display:none}.
 
In a list you can always hide columns with either css or javascript.
If you hide both the th (header) and the td of the column in question - they will not be seen in the list.
(I've done this to hide the checkboxes.)

E.g. - Assuming the table name is 'fb_report_settings' and the column/element to hide is named 'file_types'...
To use css...
Code:
th.fb_report_settings___file_types,
td.fb_report_settings___file_types{
    display:none;
}

Or, to use javascript/jquery, you can add this inside your document ready function...
Code:
jQuery("th.fb_report_settings___file_types").css("display","none");
jQuery("td.fb_report_settings___file_types").css("display","none");

But since you need to only do that on the condition the column is empty - you'd have to use javascript (jQuery) to first check the contents of the cells in that column. Like this...
Code:
var col_length = 0 ;
jQuery("td.fb_report_settings___file_types").each( function() {
        col_length = col_length + jQuery(this).text().trim().length;
});
if(col_length == 0){
    jQuery("th.fb_report_settings___file_types").css("display","none");
    jQuery("td.fb_report_settings___file_types").css("display","none");
}
 
thanks! but I have never done something with javascript in joomla. Your example was for a checkbox. Can I use this source also for a text field?

My form is called "pm_database"
The text field is called "main_participant"

Is this source correct in my case?

Code:
var col_length = 0 ;
jQuery("td.pm_database___main_participants").each( function() {
        col_length = col_length + jQuery(this).text().trim().length;
});
if(col_length == 0){
    jQuery("th.pm_database___main_participants").css("display","none");
    jQuery("td.pm_database___main_participants").css("display","none");
}

Where I have to put this javascript code in fabrik? Is this the right place? (picture: settings of the element) sry I have a german version of fabrik...


Thanks for your help :)
 
here is the screenshot: settings of the element
C:\Users\nn3241\Desktop\main_participants.png
 

Attachments

  • main_participants.PNG
    main_participants.PNG
    30.9 KB · Views: 480
here is the screenshot: settings of the element
C:\Users\nn3241\Desktop\main_participants.png
Your code looks right to me.
I don't have much luck using the individual fabrik element javascript - and this wouldn't work there anyhow as it is really javascript for the list - not the element.

There are numerous ways you can add custom javascript in fabrik lists or forms.

Have a look at this page of the Wiki (the section for 'Lists')... http://fabrikar.com/forums/index.php?wiki/javascript/
Just create a new list_xx.js file as directed in the wiki (where xx is the id of the fabrik list) - and include your code in a document ready section - like this...

Code:
jQuery(document).ready(function(){
    var col_length = 0 ;
    jQuery("td.pm_database___main_participants").each( function() {
        col_length = col_length + jQuery(this).text().trim().length;
    });
    if(col_length == 0){
        jQuery("th.pm_database___main_participants").css("display","none");
        jQuery("td.pm_database___main_participants").css("display","none");
    }
});
 
Do you mean list view or details view?
In details view empty elements have a CSS class "fabrikDataEmpty", so you can add a {display:none}.

I also want to hide labels for fields that are empty in Detail view and in emails that include form data. Where/how exactly do we use this {display:none} option?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top