jQuery UI Widgets Forums Grid Backcolor with setcolumnproperty method

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Lexi 12 years, 5 months ago.

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

  • Lexi
    Member

    hi,
    I want to change the cell backcolor with the setcolumnproperty method.
    What can I do?

    Best Regards


    Lexi
    Member

    I’ve tired like this:

    var cellValue =$("#grid").jqxGrid('getcellvalue', 1, 'firstname');
    var cellsrenderer = function (row,column, value)
    {
    return '

    ' + value+ '

    ';
    }
    $("#grid").jqxGrid('setcolumnproperty', columnName, 'cellsrenderer', cellsrenderer(1, 'firstname', cellValue));

    But it doesn’t work,pls help me .Thanks in advance.


    Peter Stoev
    Keymaster

    Hi Lexi,

    In order to modify the cell’s background, you can use a code like the one below:

    $("#jqxgrid").jqxGrid(
    {
    source: dataAdapter,
    columns: [
    { text: 'First Name', dataField: 'firstname', width: 100,
    cellsrenderer: function (row, column, value, defaultHTML) {
    return '<div style="background: #ff0000; height: 100%; color: white;"><span style="float: left; margin: 4px;">' + value + '</span></div>';
    }
    },
    { text: 'Last Name', dataField: 'lastname', width: 100 },
    { text: 'Product', dataField: 'productname', width: 180 },
    { text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right' },
    { text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' },
    { text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2' }
    ]
    });

    Hope this helps you.

    Best Wishes,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    Lexi
    Member

    Hi Peter,
    Thanks for your sample, but it is not I want.
    Here is mine: If this element has a setcellvalue method,here I define a cellsrenderer function :var cellsrenderer = function (row,column,value){
    return….;
    }.
    Then it can do like this:this.Element.jqxGrid(‘setcellvalue’,rowindex,columnname,cellsrenderer(rowindex,columnname,cellvalue)).
    The cell-value’s backcolor can changed but not cell.Base this idea ,the cell value’s forecolor can work.

    Best Regards,

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

You must be logged in to reply to this topic.