Trying to Add ColReorder - dataTables.colReorder.js:856 Uncaught TypeError: Cannot read property '_C

Trying to Add ColReorder - dataTables.colReorder.js:856 Uncaught TypeError: Cannot read property '_C

BJ HanfBJ Hanf Posts: 4Questions: 2Answers: 0
edited July 2016 in ColReorder

Getting this error
dataTables.colReorder.js:856 Uncaught TypeError: Cannot read property '_ColReorder_iOrigCol' of undefined

DataTables 1.10.11 (tried changing my version to DataTables 1.10.12, no change).
ColReorder 1.3.2

If i comment out " colReorder: true, " below the error goes away.

To my cshtml page I added

colReorder.dataTables.css by Html.CssStyles().AddStyle(Url.Content("~/js/ColReorder/colReorder.dataTables.css"));
jquery.dataTables.js // was just using jquery.dataTables.min.js before
dataTables.colReorder.js by @Html.AddScriptFile(Url.Content("~/js/ColReorder/dataTables.colReorder.js"))

in my cshtml page I have this:

  @model HelpDesk.Models.PatientListModel

      ViewBag.Title = "Patient Management";




  .... Various page elements

  <table id="tblPatients" style="padding: 0; border-collapse: separate;" class="horizseparated flatbox">
                      <th>Patient Name</th>
                      <th>Admit Date</th>
                      <th>Discharge Date</th>
                      <th>Home Phone</th>
                      <th>Work Phone</th>
                      <th>Cell Phone</th>

                      @foreach (var lt in TicketUtils.LocationTypes.Where(l => l.DisabledType == false).OrderBy(l => l.OrderByNumber))
                          <th data-serverindex="@lt.LocationTypeID" style="">
                      <th class="all">Patient Status</th>
                      <th class="all">Change Status</th>

                      int i = 0;
                      foreach (var item in Model.Patients)
                          <tr class="patientRow" id="Row@(item.PatientID)" style="cursor: pointer;">
                              <td onclick="RowClick(@item.PatientID)">
                                  <div style="min-width: 100px;">
                                      @Html.DisplayFor(m => item.FullName)
                           .... other values for Patients ....



  function createDataTables() {
                      responsive: true,
                      autoWidth: false,
                     colReorder: true,
                      destroy: true,
                      stateSave: true,
                      scrollX: true,
                      searching: true,
                      pagingType: "simple_numbers",
                      lengthMenu: [[10, 20, 50, -1], [10, 20, 50, "All"]],
                      dom: '<iBf<t>lp>',
                      order: [1,'asc'],
                      columnDefs: [{
                          targets: -2, "orderDataType": "dom-checkbox"
                          searchable: false,
                          orderable: false,
                          targets: [0,-1]
                      buttons: [
                              extend: 'colvis',
                              columns: ':not(:first-child):not(:last-child)'
                              extend: 'csv',
                              columns: ':not(:first-child):not(:last-child)',
                              extend: 'print',
                              columns: ':not(:first-child):not(:last-child)',
          table = $('#tblPatients').DataTable();

          //set hidden columns
          var hiddens = $.cookie(cookiePrefix + "hiddenColumns");
          if(hiddens !== undefined){
              var hiddenCols = new Array()
              hiddenCols = hiddens.split(",");
              // convert to ints
              for (i in hiddenCols){
              table.columns.adjust().draw( false );

   $(document).ready(function () {

  .. various other start functions


  • allanallan Posts: 52,268Questions: 1Answers: 7,958 Site admin

    Can you link to the page showing the issue so I can take a look and debug it please.


  • BJ HanfBJ Hanf Posts: 4Questions: 2Answers: 0

    The live site is a secure site, I don't have it live just in development on my desktop. send me a message and we can figure something out.

  • moktormoktor Posts: 1Questions: 0Answers: 0

    Registered to respond to this, before I realized the question is from July 2016. I had the same issue, and it was a result of having an incorrect order array:

    order: [1,'asc']

    should be order: [ [1,'asc'] ]

  • allanallan Posts: 52,268Questions: 1Answers: 7,958 Site admin

    Yes - DataTables currently needs a 2D ordering array. I made some changed to allow a 1D array on init, but it caused all sorts of issues with plug-ins and extensions. I'm going to revisit it in future, but for now, use a 2D array.


  • sqn19961016sqn19961016 Posts: 6Questions: 3Answers: 0

    moktor It's true that the format of the array is incorrect, so there's a problem in parsing.

Sign In or Register to comment.