jQWidgets Forums

jQuery UI Widgets Forums Grid add Calculated column based on data from same row

This topic contains 1 reply, has 2 voices, and was last updated by  Stanislav 7 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • douglas168
    Participant

    Hi,

    I have a jqxGrid that gets data in json format from remote url. One of the jqxgrid columns has a column named birthyear and I need to ADD another column in the jqxgrid that shows age (from current year).

    I tried to use cellsrenderer such as below but the jqxgrid stops rendering when it hits this column. What am I doing wrong and how do fix it or is there another way to accomplish the same thing. Appreciate the help! –Douglas

    {
                        text: 'Age',
                        datafield: 'age',
                        width: 100,
                        renderer: headerrenderer,
                        cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
                            var d = new Date();
                            var todayYear = d.getFullYear();
                            var rowData = $("#jqxGrid").jqxGrid('getrowdata', row);
                            var age = todayYear - rowData.birthYear;
                            return '<div style="text-align: center; margin-top: 5px;">' + age + '</div>';
                        }
                    },

    Stanislav
    Participant

    Hello Douglas,

    Here is an example: Link

    In this example, the unitPrice column gets subtracted from the quantity column.
    It shows the basic idea that you need to follow for your case.
    I even tried it with the new Date() function and it worked.

    Best Regards,
    Stanislav

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.