jQuery UI Widgets Forums Grid cell format

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 9 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    cell format Posts
  • cell format #68535

    nico77
    Participant

    Good evening,
    Is it possible format the same cell in different rows in different way?

    i show an example of my code:

    
    function carica_statistiche() {
    
        var url = "statistiche.php" ;
        // prepare the data
          var source_stat =
                {
                    datatype: "json",
                    datafields: [
                        { name: 'descrizione', type: 'string' },
                        { name: 'tipo', type: 'int' },
                        { name: 'result', type: 'decimal' },
                        
                    ],
                    url: url
                }; //Fine source
                
                
                var dataAdapter = new $.jqx.dataAdapter(source_stat,{}
                    );//fine dataadapter
                
    
                var formatocelle = function (row, column, value, data) {
                    if (data.tipo==3)
                    {
                        return "d";
                    }
                    else
                    {
                        return "d3";
                    }
                };
                
            
    
                //var formatocelle ='d2'
    
                        
                $("#jqxgrid").jqxGrid(
                {
                    width: 802,
                    height: 700,
                    rowsheight: 25,
                    altrows: true,
                    source: dataAdapter,
                    columnsresize: true,
                    theme:"orange",
                    showtoolbar: true,
                    localization: getLocalization('it-IT'),
                    
                    columns: [
                    
                      { text: 'Descrizione', datafield: 'descrizione', cellsalign: 'LEFT', width: 650},
                      { text: 'Totale', datafield: 'result',cellsalign: 'center',cellsformat:formatocelle, width: 150},
                  ]
                }); //fine grid
    

    I’ve tried to set the value of “formatocelle” looking for the value of the field “tipo”, but it doesn’t work. The grid doesn’t load any data.

    if i remove the code:

    var formatocelle = function (row, column, value, data) {
                    if (data.tipo==3)
                    {
                        return "d";
                    }
                    else
                    {
                        return "d3";
                    }
                };
    

    and replace it with “var formatocelle =’d2′” it works, but so every cell has the same format.

    thanks

    cell format #68539

    Peter Stoev
    Keymaster

    Hi nico77,

    cellsformat expects a string, not a function. This means that if you pass Function, this will not work. However, this could be a nice enhancement for a future release.

    Best Regards,
    Peter Stoev

    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.