Hide "Remove all" and "Remove Row" from MRVS?

RJ12
Mega Guru

Hi folks,

I tried using DOM manipulation to hide "Remove all" and "Remove Row" from MRVS, but unfortunately, it didn't worked out. Went through few codes across community but no luck.

Here's my code:

For "Remove all"

function onLoad() {
//Type appropriate comment here, and begin script below
//Hide Remove All button on MRVS
var btn = this.document.getElementsByClassName("btn btn-default");
for (i = 0; i < btn.length; i++) {
if (btn[i].innerText == 'Remove All') {
btn[i].style.display = 'None';
}
}
}

For Remove Row:

function onLoad() {
//Hide each X (delete row) icon on MRVS
var icon = this.document.getElementsByClassName("wrapper-xs fa fa-close");
for (j = 0; j < icon.length; j++) {
if (icon[j].getAttribute("title") == 'Remove Row') {
icon[j].style.display = 'None';
}
}
}

 

find_real_file.png

find_real_file.png

 

Can you please help me out ? Wondering what I'm missing here. As, I'm still able to see those two icons on my SP.

Thanks 

Cheers,

RJ

 

1 ACCEPTED SOLUTION

Yes! did tried those steps but no luck whatsoever.

Anyway, in the above code I've changed it a bit and now "Remove Row" button is hidden on MRVS.

function onLoad() {
 setTimeout(function() {
        disableButtons();
    }, 500);
}

function disableButtons() {
    var my_var = g_form.getField("mvrs_internal_name"); 
    var icon = this.document.getElementsByClassName("wrapper-xs fa fa-close");
    for (i = 0; i < icon.length; i++) {
        //alert(icon[i].getAttribute("data-original-title"));
        if (icon[i].getAttribute("data-original-title") == 'Remove Row') {
			icon[i].style.display = 'None';
        }
    }
}

So, in if condition I've replaced existing condition with :

    if (icon[i].getAttribute("data-original-title") == 'Remove Row')

 

And, eventually, that button/Remove Row is hidden on MRVS.

Cheers,

RJ

 

View solution in original post

5 REPLIES 5

And, used this code for hiding "Remove all", working impeccable for me:

function onLoad() {
    setTimeout(function() {
        disableButtons();
    }, 500);
}

function disableButtons() {
    var vs = g_form.getField("variable_set_internal_name");
    vs.max_rows_size = 0;
    var btn = this.document.getElementsByClassName("btn btn-default");
    for (i = 0; i < btn.length; i++) {
        if(btn[i].innerText == 'Remove All') {
            btn[i].disabled="disabled";
        }
    }
}