Sorting is not working at server side processing

Sorting is not working at server side processing

raji.godugula@gmail.comraji.godugula@gmail.com Posts: 5Questions: 4Answers: 0

I have used jquery data table in my application, I am trying to assign data at server side since it is huge data. when i try to write sorting code at server side, i am trying to get sortcolumn by using below code, it is working at first time and I could able to sort. but when I perform any search operation and then try to load data , it is throwing exception at the place where I am getting sort column info . Please help me to get sort column if any other way ?

var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();

Answers

  • robertoltrocharobertoltrocha Posts: 2Questions: 0Answers: 0
    edited May 2018

    PUT this columin this struct:

    columns: [{ data: "CORID","name":"CORID" },
                    { data: "DESCRICAOCOR","name":"DESCRICAOCOR" }
    
      $('#dataTable').DataTable({
                processing: true,
                serverSide: true,
                searchable: true,
                "aaSorting": [[0, "asc"]],
    
                ajax: {
                    url: '@Url.Action("GetOrganizations")',
                    type: 'POST',
                    dataSrc: 'data',
                },
                columns: [{ data: "CORID","name":"CORID" },
                    { data: "DESCRICAOCOR","name":"DESCRICAOCOR" }
                    
                ]
            });
    
  • robertoltrocharobertoltrocha Posts: 2Questions: 0Answers: 0

    repeat "name" in all field to pass the column name

This discussion has been closed.