showing nan of nan

showing nan of nan

AlexEAlexE Posts: 1Questions: 1Answers: 0

I am converting a DataTable to use serverside processing to reduce load times and I cannot for the life of me work out why the footer isn't working.

I am using DataTables 1.8.4 I think.

Most answers I have come across mention iTotalDisplayRecordsneeds to be present and accurate which I believe it is.

So if anyone can help me it would be fantastic.

Due to the data being private I can't show you a copy but here is the code and JSON.

The jQuery

if ($(this).hasClass("customerOrderTable")) {
                    $(this).dataTable({
                        "bPaginate": true,
                        "iDisplayLength": 25,
                        "aLengthMenu": [10, 25, 50, 100],
                        "sPaginationType": "full_numbers",
                        "aaSorting": [[s, sdir]],
                        "bServerSide": true,
                        "sAjaxSource": "PathToController?RequestId=" + requestId,
                        "bProcessing": true,
                        "aoColumns": [
                            { "sName": "OrderNumber" },
                            { "sName": "OrderDate" },
                            {
                                "sName": "OrderStatus",
                                "fnRender": function (oObj) 
                                {
                                    return "<span class='badge " + oObj.aData[9] +"'>" + oObj.aData[2] + "</span>";
                                }
                            },
                            { "sName": "DeliveryDetails" },
                            { "sName": "InvoiceDetails" },
                            { "sName": "Value" },
                            { "sName": "Balance" },
                            { "sName": "CustomerType" },
                            {
                                "sName": "Details",
                                "bSearchable": false,
                                "bSortable": false,
                                "fnRender": function (oObj) 
                                {
                                    return "<a class='btn btn-mini' href='PathToController"
                                        + oObj.aData[8] + "'>Details...</a>";
                                }
                            }
                        ]

                    });
                }

The Controller

var customerQuery = (from c in customer.Orders
                                 select c);

            int totalRecords = customerQuery.Count();

            if (!string.IsNullOrEmpty(requestModel.sSearch))
            {
                customerQuery = customerQuery.Where(c => c.OrderNumber.Contains(requestModel.sSearch)
                || c.DeliveryLastname.Contains(requestModel.sSearch)
                || c.DeliveryAddress1.Contains(requestModel.sSearch)
                || c.DeliveryPostcode.Contains(requestModel.sSearch)
                || c.InvoiceDelivery.ToString().Contains(requestModel.sSearch));
            }

            var orderResult = Helpers.Contact.GetCustomerOrdersList(customer, requestModel);

            int totalDisplay = customerQuery.Count();

            return Json(new
            {
                sEcho = int.Parse(requestModel.sEcho),
                iTotalRecords = totalRecords,
                iTotalDisplayRecords = totalDisplay,
                aaData = orderResult,
                //iDisplayStart = requestModel.iDisplayStart,
                //iDisplayLength = requestModel.iDisplayLength
            },
            JsonRequestBehavior.AllowGet);
        }

The helper class:

var customerQuery = (from c in entity.Orders
                             select c);

        //I am aware the ordering wont work until this is updated
        customerQuery = customerQuery.OrderBy(c => c.OrderNumber);

        if(!string.IsNullOrEmpty(requestModel.sSearch))
        {
            customerQuery = customerQuery.Where(c => c.OrderNumber.Contains(requestModel.sSearch)
            || c.DeliveryLastname.Contains(requestModel.sSearch)
            || c.DeliveryAddress1.Contains(requestModel.sSearch)
            || c.DeliveryPostcode.Contains(requestModel.sSearch)
            || c.InvoiceDelivery.ToString().Contains(requestModel.sSearch));
        }

        customerQuery = customerQuery.Skip(requestModel.iDisplayStart).Take(requestModel.iDisplayLength);

        ICollection<Business.OrderSummaryModel> ordersList = (from c in customerQuery
                                                              select Business.OrderSummaryModel.MapEntityToSummaryModel(c)).ToList();

        var result = (from x in ordersList
                      select new[] {
                        x.OrderNumber,
                        x.OrderDate.ToString(),
                        x.OrderStatus,
                        x.DeliveryName + "/" + x.DeliveryPostcode,
                        x.BillingName + "/" + x.BillingPostcode,
                        x.Currency + x.InvoiceGrandTotal.ToString("#,##0.00"),
                        x.Currency + x.OutstandingBalance.ToString("#,##0.00"),
                        x.CustomerType,
                        x.Order_ID.ToString(),
                        x.StatusClass

                    });

        return result;

JSON

{
"sEcho":"1",
"iTotalRecords":25,
"iTotalDisplayRecords":25,
"data":
[
["001",
    "26/06/2013 14:03:27",
    "Dispatched",
    "TheCustomer1",
    "Address1",
    "Value1",
    "Type1",
    "ID1",
    "ExtraData1"
],
[
    etc
],

Is anyone able to help me?

This discussion has been closed.