Giter VIP home page Giter VIP logo

Comments (5)

eherve avatar eherve commented on September 10, 2024

Hi,

Thanks for your feedback.

When you say you can't select those fields, you mean you don't see them on the datatable (client side) ?
Did you try to see what was in the object data you get from model.dataTable (server side) ?

Regards,

from mongoose-datatable.

ricardofbarros avatar ricardofbarros commented on September 10, 2024

I tried both, but more importantly on server side it should select those fields which they didn't, they were regulated by aoColumns -> mData fields take this practical example:

Server side

    var options = {};
    options.select = 'campaign';
    model.dataTable(req.query, options, function(err, data) {
        res.json(data);
    });

Client side

$('#data-Table').dataTable({
  "bProcessing" : true,
  "bServerSide" : true,
  "sAjaxSource" : '{{ route("phone_list.list") }}',
  "aoColumns" : [
    { "mData" : "campaign" },
    { 
      "sName": "RoleId",
      "bSearchable": false,
      "bSortable": false,
      "mRender": function (data, type, full)                            
      {
        var id = full['number'];
        return "<a href='#"id+"'>"+
        "<button class='btn btn-primary btn-circle'>"+
        "<i class='fa fa-list' style='font-size:18px'></i></button> </a>";
      }
     }
  ]
}); 

data would produce something like

{ sEcho: '2',
  iTotalRecords: 52,
  iTotalDisplayRecords: 52,
  aaData: 
   [ { _id: 53bfc5e8beb14ce414050e2e,
       campaign: 'test #1' },
     { _id: 53bfc4e9a16b7eba13cafe63,
       campaign: 'test #2' }
] }

which is wrong , the ideal output would be

{ sEcho: '2',
  iTotalRecords: 52,
  iTotalDisplayRecords: 52,
  aaData: 
   [ { _id: 53bfc5e8beb14ce414050e2e,
       campaign: 'test #1',
       number : 1234 },
     { _id: 53bfc4e9a16b7eba13cafe63,
       campaign: 'test #2',
       number: 2345 }
] }

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

Hi,

There was a bug with the options.select as string...
I corrected it and pushed it, it is also available on npm (mongoose-datatable v0.2.7)

It should correct your issue, let me know if it is ok for you now

Regards

from mongoose-datatable.

eherve avatar eherve commented on September 10, 2024

I also have updated the test to add a column retrieved with options.select

from mongoose-datatable.

ricardofbarros avatar ricardofbarros commented on September 10, 2024

Okay with string works fine, but with arrays it doesn't work

    var options = {};
    options.select = ['provider' , 'id'];
    model.dataTable(req.query, options, function(err, data) {
        res.json(data);
    });

I took the liberty to fix this bug, I will open a new ticket with the code fixed, I can't push it from here :(

from mongoose-datatable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.