I receive table.row is not a function, while using meteor's aldeed:tabular

I receive table.row is not a function, while using meteor's aldeed:tabular

ecuanasoecuanaso Posts: 3Questions: 2Answers: 0

So what i'm trying to basically do is add parent/row method per the doc https://datatables.net/examples/api/row_details.html on to my meteor project but i'm getting error 'table.row is not a function'

Here's the code that I'm working on->

    function format ( d ) {
        // `d` is the original data object for the row
        return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
            '<tr>'+
                '<td>Full name:</td>'+
                '<td>'+d.name+'</td>'+
            '</tr>'+
            '<tr>'+
                '<td>Extension number:</td>'+
                '<td>'+d.extn+'</td>'+
            '</tr>'+
            '<tr>'+
                '<td>Extra info:</td>'+
                '<td>And any further details here (images etc)...</td>'+
            '</tr>'+
        '</table>';
    }

      var Tabular = null;

      if (Package['nicolaslopezj:tabular-materialize']) {
          Tabular = Package['nicolaslopezj:tabular-materialize'].Tabular;
      }

      if (Package['aldeed:tabular']) {
          Tabular = Package['aldeed:tabular'].Tabular;
      }

      if (!Tabular) {
        throw new Meteor.Error('orion', 'You must install tabular to use this package');
      }

    var table = orion.pages.tabular = new Tabular.Table({
        name: 'PagesIndex',
        collection: orion.pages.collection,
        order: [[1, "desc"]],
        // autoWidth: false,
        columns: [
          {
            className:      'details-control',
            orderable:      false,
            data:           null,
            defaultContent: ''
          }, 
          { data: 'title', title: i18n('pages.schema.title')},
          { data: 'url', title: i18n('pages.schema.url'), render: function(val, type, doc) { return '<a href="' + RouterLayer.pathFor('page', doc) + '">' + RouterLayer.pathFor('page', doc) + '</a>'; } },
          { data: 'position', title: 'Order',
              render: function( val, type, doc) {
                return '<input data-id="' + doc._id + '" type="number" value="' + val + '" class="order-pages">'
              }
          }, 
          { data: 'actions', orderable: false, title: 'Actions',
              render: function (val,type,doc){
                return '<a href="' + Router.path('pages.update', doc) +'" class="btn waves-effect waves-light light-blue accent-4 user-btn-action">Edit</a>'
              },
             tmpl: Meteor.isClient && Template.actionBtns
          }
        ]
      });

    Template.orionMaterializePagesIndex.onRendered(function(){
      $('.table').on('click', 'td.details-control', function () {
        alert('go');
        console.log(table);
        var tr = $(this).closest('tr');
        var row = table.row( tr );

        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
      });
    });

Is there extra files I have to install or there's something wrong with my format?

Answers

  • allanallan Posts: 61,946Questions: 1Answers: 10,158 Site admin

    I can only guess that new Tabular.Table({ is not returning a DataTables API instance. You would need to take a look into that library or ask its author to see what it is actually returning and how you can get an API instance.

    Allan

  • ecuanasoecuanaso Posts: 3Questions: 2Answers: 0

    Thanks Allan for your timely response. I'll ask the author and report back.

This discussion has been closed.