eherve / mongoose-datatable

Server side dataTable request support for mongoose
MIT License
42 stars 28 forks source link

data table get a row data #35

Closed yingca1 closed 5 years ago

yingca1 commented 9 years ago

before i use this plugin, i get a row data in datatables by

       jQuery('.js-dataTable-full').dataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "/path/to/request/ajax",
            "createdRow": function(row, data, index) {
                  // todo something
            },
            "columnDefs": [{
                "targets": 0,
                "data": function ( row, type, val, meta ) {
                    return row;
                },
                "className": "text-center",
                "render": function ( row, type, full, meta ) {
                  // !!! i want to get the row data and do something at here
                  return '<a>' + row.name + '</a>';
                }
            }],
        });

when i use this plugin i get the error: [Error: No valid field requested !]

i open the log and find the root cause:

in the file field.js i get a error Field Error: Unknown field path function ! error throw from here

if (!loadSchemaInfo(model, info, model.schema, path))
    throw Error(util.format("Unknown field path %s !", path));

the data field does not support function.

and then how can i get a full row data in datatables? plz give me some tips.

thanks.

eherve commented 9 years ago

Hello,

Sorry to reply this late... Thanks for using this plugin.

There are no way to retrieve the full row data in this plugin, this plugin was design to retrieve only requested fields. Do you still need such feature ?

lecai commented 7 years ago

hi~ @eherve @icaiying i also have a same need. is any idea to finish such feature?

eherve commented 5 years ago

Hi @lecai , sorry for the very very late reply...

This module does not implement raw fetch of model. You can achieve this by adding all the fields you need in the options.select parameter of model.datatable method.

Regards,