Show/Hide Columns in List or Library Control

Hi Plumsail,

Is it possible to do a show/hide on a SharePoint list?

I already have a list view set-up but I was wondering if you could show/hide columns using a button?

Thank you!

Dear @Qman,
You can hide a column with the following method, using either index or name of the column:

fd.control('SPDataTable1').widget.hideColumn(5)
//or
fd.control('SPDataTable1').widget.hideColumn("Status")

You can also show column with a similar method:

fd.control('SPDataTable1').widget.showColumn(5)
//or
fd.control('SPDataTable1').widget.showColumn("Status")
1 Like

Bonjour,
Je n'arrive pas à faire fonctionner ce fd.control
Fonctionne-t'il toujours sur la version 1.9 pour Sharepoint Server?

Bien à vous,
Aurore

Dear @auroret,
Can you include a screenshot of your code? Also, check browser's console for errors, and send a screenshot as well.

Merci pour votre réponse.

function CacherH()
{
fd.control('TabBio').widget.hideColumn("Hbio");
}
CacherH();

Dear @auroret,
Are you using anything else? The code needs to be wrapped inside appropriate events:

fd.spRendered(function() {
    fd.control('TabBio').ready().then(function(dt) {
        dt.widget.hideColumn("Hbio");
    });
});

Also, if it's not dynamic, you can just create a list view with this column hidden, and select for your List or Library datasource.

Bonjour,

J'ai initialement créé des vues directement dans la liste mais j'ai actuellement une dizaine de vues et ce n'est pas pratique...
J'ai en effet besoin d'un filtre dynamique en fonction de conditions

fd.spRendered(function()
function CacherMo()
{
if (fd.field('BinaireMo').value==0)
{
fd.control('TabBio').ready().then(function(dt)
{
dt.widget.hideColumn("H_bio");
dt.widget.hideColumn("NM3_bio");
dt.widget.hideColumn("kW");
dt.widget.hideColumn("kW2");
dt.widget.hideColumn("kWhcalc");
}
}
else
{
fd.control('TabBio').ready().then(function(dt)
{
dt.widget.showColumn("H_bio");
dt.widget.showColumn("NM3_bio");
dt.widget.showColumn("kW");
dt.widget.showColumn("kW2");
dt.widget.showColumn("kWhcalc");
}
}
}

    function CacherChau() 
        {
        if (fd.field('BinaireChau').value==0)
            {
            fd.control('TabBio').ready().then(function(dt) 
                {
                dt.widget.hideColumn("Hchaud");
                dt.widget.hideColumn("NM3chau");
                }
            }
        else
            {
            fd.control('TabBio').ready().then(function(dt) 
                {
                dt.widget.showColumn("Hchaud");
                dt.widget.showColumn("NM3chau");
                }
            }
        }

Dear @auroret,
Check browser's console for errors and send us a screenshot of console when opening a form.