Formulas and Data Tables, client or server sided?

Formulas and Data Tables, client or server sided?

sm1l3ysm1l3y Posts: 24Questions: 7Answers: 0

What works best with and/or does data tables prefer when it comes to formulas, done by client sided (js) or server sided (c#, sql, etc)? For example a column which content is generated by a formula which includes other columns or even the sum of another?

This question has an accepted answers - jump to answer

Answers

  • ApezdrApezdr Posts: 43Questions: 4Answers: 5
    Answer ✓

    It would depend on the calculations you're looking to do. Client side is easiest to implement and maintain using the following example below.

    table = $('#ClientData').DataTable( {
                    ajax: ajaxURL,
                    columns: [
                    {
                        "title":"Client Name",
                        "data": "ClientData.ClientName",
                        "render": function ( data, type, row ) {
                            return data + '%';
                        }
                    },
    

    In this example it is relatively easy to do calculations at run-time as opposed to doing it server side. If you're doing it server side it could potentially make things faster for the user but its negligible from my experience.

  • sm1l3ysm1l3y Posts: 24Questions: 7Answers: 0

    Thank you, any idea how i would also access the footer and a column for a calculation?

  • ApezdrApezdr Posts: 43Questions: 4Answers: 5

    From my knowledge the built in excel generation is a bit of a tricky beast to work with. I'd defer to someone else for this question but it's a good one I've had myself.

  • allanallan Posts: 62,211Questions: 1Answers: 10,206 Site admin

    The footer can be access using column().footer().

    Allan

  • sm1l3ysm1l3y Posts: 24Questions: 7Answers: 0

    For future reference for anyone, I did the calculations upon the returned JSON data before passing it to the data tables API. For instance AJAX call > resulting data into JSON > custom calculations > then passed to data tables api.

This discussion has been closed.