Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81799

data-order not work using Ajax datasource

$
0
0

I'm trying to set the correct sorting value for a date column.
My table is populated via ajax. The datasource contains 2 values for date field: one to be displayed and formatted depending by the UI language (field:SendDate), and one to be used by datatables for ordering the column (field: DataOrder).
I've tried to use the 'data-order' attribute in the follwing way:

                {
                    "targets": 2,
                    "createdCell": function (td, cellData, rowData, row, col) {
                        $(td).attr("data-order", rowData.DataOrder);
                    }
                }

but it doesn't work.
I've tried setting sort property like in this post

        {
            "data": {
                type: '@data-order',
                sort: '@data-order'
            },
                var rclass = "read";
                if (tipoRecord === 'R')
                    rclass = data.Letto ? "read" : "toread";
                return "<div class='font-size-sm line-height-1 " + rclass + "'>" + data.SendDate + "</div>";
            }
        },

but throw the error Cannot read property 'SendDate' of undefined.
How can I set the correct order for this column?

Thanks

Edika


Viewing all articles
Browse latest Browse all 81799

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>