We help IT Professionals succeed at work.
Get Started

DataView Web Part - Datatables JQuery. Removing filtering/sorting from SharePoint

Last Modified: 2016-10-15
We moved to SharePoint Online and I am trying to use some code I put together to pull in a Dataview web part and then have the table search able using Datatables.js

I was having trouble figuring out how to turn off the filtering and the sorting that is native to the SharePoint webpart so I opted to hide that row and replace it was a new row that is generated by script.

However, it appears that when Datatables is staging the table to display it is ignoring this new row that was added programatically.

I had to find the table based on a custom attribute and then force an ID attribute and that is all working. I just can't get the new row to become part of the DataTable display.

This is the code.  Any suggestions?


$('table[summary="2CIA4_Rules "]').attr('id','ruletable');
$('#ruletable > tbody').prepend('<tr><td>Rule</td><td>Owner</td><td>Audience</td><td>Curriculum</td><td>Target Area</td><td>Leader</td><td>Leader_WWID</td><td>MRC</td><td>Legal</td><td>JobFunction</td><td>SubFunction</td><td>Exclusions</td><td>Year 4 Notes</td><td>Comments</td><td>ChangeNotes</td></tr>');

$( ".ms-listviewtable" ).DataTable( {
		dom: 'Tf<"clear">rtip',
        "scrollY":        "600px",
		"scrollCollapse": true,
		"paging":         false
} );

var table = $( ".ms-listviewtable" ).DataTable();

//table.column(13).visible( false );
//table.column(14).visible( false );
} );

Open in new window

Watch Question
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE