0

I have a sharepoint 2013 list. Using data tables am retrieving the list data into a data table. How to reduce the width of particular columns in data table?

Thanks in advance.

3
  • anyone know the solution?
    – Dheeraj
    Commented Apr 20, 2017 at 15:17
  • is it javascript ? or C#? Commented Apr 20, 2017 at 15:43
  • I have done it using jquery
    – Dheeraj
    Commented Apr 21, 2017 at 8:49

2 Answers 2

0

Add the following script to script editor or content editor webpart. Replace the Column name to column name you want to increase the width

    <script src="/PublishingImages/javascript/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
            $(function(){$("TH.ms-vh2-nograd:contains('Column 1')").css("width", "350px");

            $("TH.ms-vh2-nograd:contains('Column 2')").css("width", "350px");

             });

    </script>
1
  • Not in the form...I need to reduce it in the datatable
    – Dheeraj
    Commented Apr 21, 2017 at 8:48
0

Try the below code to adjust the column width in data table

For the first column

$('#example').dataTable( {
  "columnDefs": [
    { "width": "20%", "targets": 0 }
  ]
} );

For more details check columns.width

For a specific column.

   $('#table_1').DataTable({
    columns: [
        { data: 'id', name: 'id' , width: '50px', class: 'text-right' }
    ]
    });

Ref: Setting column width

2
  • I have tried this...It dint work
    – Dheeraj
    Commented Apr 21, 2017 at 11:10
  • add your code in your question to can help you accurately Commented Apr 21, 2017 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.