DataTables Produces Empty Records

DataTables Produces Empty Records

cworkmancworkman Posts: 10Questions: 4Answers: 0
edited November 2014 in Free community support

Hi all!

First I want to say thanks for the excellent product.

I'm currently facing a problem that I can't seem to solve.

I am selecting records from a table where some fields are missing a value. When I do this I use the query below to select only those that have values.

C#

return Json(new
            {
                param.sEcho,
                iTotalRecords = allCigByZipTaxReport.Distinct().Count(),
                iTotalDisplayRecords = cigByZipTaxReport.Distinct().Count(),
                aaData = result.Where(x => (string.IsNullOrEmpty(x.FipsCounty) == false)
                && (string.IsNullOrEmpty(x.ZipCode) == false)
                && (string.IsNullOrEmpty(x.CigTax.ToString()) == false)
                ).Select(x => new[] { x.FipsCounty, x.ZipCode, String.Format("{0:0.00000}", x.CigTax) })
            },
            JsonRequestBehavior.AllowGet);

I'm not sure if this is a server side or data tables issue. When I do this I get a "no matching records" message within the table. However, if I navigate further into the records they will eventually show up (ex: Page 20).

Any idea as to what's happening here?

Thanks,
Channing

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,933Questions: 1Answers: 10,154 Site admin
    Answer ✓

    What is the JSON that is being returned from the server when you get that message? I'm guessing that aaData is an empty array which would suggest that the issue is that the result.Where is returning an empty result set on the server-side.

    Allan

  • cworkmancworkman Posts: 10Questions: 4Answers: 0

    Allan,

    Thank you for your quick response! You were correct on the JSON results. I created a few views in sql server and queried those into the datatable. It worked like a charm.

This discussion has been closed.