How to enlarge columns for List or Library Control

I'm having issue whereby the columns for List or Library control is not standardise and cannot be alter. How to do it? How to make the columns width bigger/smaller since my users prefer to fill up those items inline rather than dialog?

Hello @noorshahida88!

Please use the following code in JavaScript Editor to set the List or Library control column width.
Where SPDataTable0 is the internal name of the List or Library control and i in columns[i] is the column position.

  fd.spRendered(function() {
  var columns = $(fd.control('SPDataTable0').$el).find('col');
  console.log(columns);
  $(columns[i]).attr("style","width:500px");
  });

Hello @mnikitina,

Doesn't change anything. Moreover, I didn't understand of console.log which I don't see anything after I press F12.

@noorshahida88,

Please try the code below, it should change the "Documents" column weight, as its position is 2. Just replace SPDataTable0 with the internal name of the List or Library control.

fd.spRendered(function() {
    fd.control('SPDataTable0').ready().then(function(dt) {
		var columns = $(fd.control('SPDataTable0').$el).find('col');
		$(columns[2]).attr("style","width:500px");
    });
});
1 Like

Thanks @mnikitina

1 Like

Hi mnikitina.

The code you provided works for an inline list/library control when there are a few columns/fields. However, on an inline list/library control with more columns/fields (23 fields in my case) the code to expand the columns for some reason doesn't work and I'm not sure why. Can you try to duplicate on on your end and let us know the resolution?

Thanks,
stormanh

@stormanh,

Could you please share the screenshot of the 'List or Library' control and the script you are using.

Do you have any messages in the console?

What is the column type: string, drop-down, date, etc? What is the column position?

Hi, is this code still works for columns more than 10 since i tried for column 14th but nothing change.

@noorshahida88,

Do you have any messages in the console?

What is the column type: string, drop-down, date, etc? What is the column position?