jQWidgets Forums

jQuery UI Widgets Forums Grid Grid balance

Tagged: ,

This topic contains 7 replies, has 2 voices, and was last updated by  taskmate 8 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Grid balance Posts
  • Grid balance #84007

    SysProfile
    Participant

    Please excuse the English translation that makes Google Translate

    I have to solve the following:
    In the “A” column I have a string, in the “B” and “C” column I have numerical values. The “D” column should reflect the calculation of the column “B” minus the “C” column, where the “A” column has the same value. An example below.

    A        B        C        D
    Data 1   10        2       8
    Data 1             2       6
    Data 2   50        2      48
    Data 2            10      38

    To be clear, I need a balance. It is very important that the “D” column format is maintained, in this case, right-aligned and formatted d2

    Best Regards,
    Sergio Haurat

    Grid balance #84009

    taskmate
    Participant

    Sir

    This may not be the best as the code but what I suggest is

    $(‘#jqxgrid’).on(‘bindingcomplete’, function (event) {
    var rows = $(‘#jqxGrid’).jqxGrid(‘getrows’);
    for (var i = 0; i < rows.length ; i++){
    var bvalue = rows[i][‘b’];
    if (i ==0){
    if (!bvalue){bvalue = 0;}
    } else {
    bvalue = rows[i-1][‘d’];
    }

    var cvalue = rows[i][‘c’];
    if (!cvalue){cvalue = 0;}
    var dvalue = parseInt(bvalue) – parseInt(cvalue);
    $(“#jqxgrid”).jqxGrid(‘setcellvalue’, 0, “d”, dvalue);
    }
    });

    Grid balance #84012

    SysProfile
    Participant

    Thanks for your suggestion, that you propose would happen in “bindingcomplete” would be best to do it on “cellsrenderer” or “renderer” it is much difference between a performance and a method.

    Grid balance #84015

    taskmate
    Participant

    Hi

    I am not sure but bindingcomplete would be called once and cellrender would be called [no of rows * no of columns];

    But if there is problem on bindingcomplete obviously it can be called on cellrender

    Regards

    Grid balance #84066

    SysProfile
    Participant

    I develop a function in javascript, the problem is that when update the value in the cell, the format is “destroyed” completely

    Grid balance #84067

    taskmate
    Participant

    Hi

    Have you tried using

    var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {
    if (value < 20) {
    return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘; color: #0000ff;”>’ + value + ‘</span>’;
    }
    else {
    return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘; color: #008000;”>’ + value + ‘</span>’;
    }
    }

    Regards

    Grid balance #84105

    SysProfile
    Participant

    @taskmate, I saw that code but does not respect the format of the cell, I have thousands and decimal separator.

    Grid balance #84106

    taskmate
    Participant

    SysProfile

    You create the string with said format and pass the value to the grid as string. If the data type is string column will not change format.

    Sanjay

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

You must be logged in to reply to this topic.