jQWidgets Forums

jQuery UI Widgets Forums Grid Conditional row format

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  morgenweck 11 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Conditional row format #47623

    morgenweck
    Participant

    Is there a way to format an entire row based upon the value in a particular cell? I see how to format a cell but how would I pass the value of a different cell to the cell render?

    Conditional row format #47625

    Peter Stoev
    Keymaster

    Hi morgenweck,

    To format an entire row, you will need to have “cellsrenderer” callback function for all columns.

    Example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/editrowsrendering.htm?arctic

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Conditional row format #47648

    morgenweck
    Participant

    I’m using
    var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {
    if (value === ‘NY’) {
    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>’;
    }
    }
    for the cell that has the condition that I want to format but how do I pass the same value for other cells?

    my grid looks like

    City State Zip

    how do I render the City and Zip cells based upon the State’s value?

    Conditional row format #47649

    morgenweck
    Participant

    I got it I used

    var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {
    var datarow = $(“#subgrid3″).jqxGrid(‘getrowdata’, row);

    if (datarow.State === ‘NY’) {
    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>’;
    }
    }

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

You must be logged in to reply to this topic.