Rename button on list/library control

Hello,

I'm trying to rename 'Add new item' button on a list/library control using the code from the documentation
fd.control('SPDataTable1').addNewItemText = "New text"

I have put this inside the fd.spRendered(function() { however it doesn't do anything?

Please tell me what I'm doing wrong

I would also like to know how to change the Add new item text. Thanks

Hello @Office365guy, @WRSIT,

You can change the text of the button with the following code.

fd.control('SPDataTable0').buttons[0].text = "New Item Text"

fd.spRendered(function() {
alert('Starting');
fd.control('SPDataTable1').buttons[0].text = 'Add new'
});

had no effect, thanks! I'm sure I'm missing simple. Thanks

@Office365guy,

Please use the following code in JavaScript Editor. Please double-check the internal name of the control. If the button text still won't change, please check if there are any errors in the console (F12) and share the screenshot of it.

fd.spRendered(function() {

	alert('Starting');

	fd.control('SPDataTable1').buttons[0].text = 'Add new';

});

image

@Office365guy,

Please run the following code in the browser console and share the screenshot of the extended results.

fd.control('SPDataTable1').buttons

image

Picture1

Looks OK to me

If I use the fd.control('SPDataTable1').buttons[0].text = 'New Modifier'; in the console it works?? I'll try adding the script to the on ready function for the list control.

I'm using Chrome

This worked:

window.fd = fd;
fd.spRendered(function() {
fd.control('SPDataTable1').ready().then(function(dt) {
dt.buttons[0].text = 'New Modifier';
});
});

1 Like