Problem DataTable ccs Partial View, AJAX, C#.

Problem DataTable ccs Partial View, AJAX, C#.

pabloapabloa Posts: 2Questions: 1Answers: 0

Hi people, im working with DataTables 1.10.13 in my application. Basically i load the view index of my controller (that view has DataTables to print the evaluations) with all the evaluations that are loaded in the app.
I have a form to search for these evaluations, the data send to my controller vía AJAX and that controller, depending of the data, returns a PartialView (the same one that was charged by request get) with the same DataTable but another evaluations.

In my Ajax function i receive the view with the all data and then I put it with .html(data) in my div. The problem is when i receive the data through AJAX and i put it in my div, the header of my table returns unordered, unlike when the first time is loaded via url (get). Sometimes returns good thats what i like but another times returns unordered.
I added two images where you see what I want to explain. the first is the good one and the second, not.

There is my configuration DataTables:

$(document).ready(function () {
$('#Evaluates').dataTable({
"scrollY": "15vw",
"scrollX": true,
"scrollCollapse": true,
"paging": true,
"fixedColumns": false,
"ordering": false,
"searching": false,
"info": true,
"language": {....

If someone can help me I would be grateful.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @pabloa ,

    With your configuration, DataTables just initialises on the table in the DOM, so it's doing everything right. As you say, the problem is with your controller and how it creates that data with is outside of the scope of this forum. All I can suggest is following the code through, and seeing where and how the columns are ordered in that controller.

    Cheers,

    Colin

  • pabloapabloa Posts: 2Questions: 1Answers: 0

    I already solved the problem. thanks for the reply

This discussion has been closed.