Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #102895
    ufficio.it
    Participant

    Hi,

    I have a grid with some cell style that change depending on data it contains. The function on the first page of the grid work only if I change the page (go to second page) and the return to first (must change the color of the cell).

    ex:

    var sel=//change with a select
    new window.Smart(‘#grid1’, class {
    get properties() {
    return{
    appearance: {
    alternationCount: 2
    },
    paging: {
    enabled: true,
    pageSize: 20
    },
    pager: {
    visible: true
    },
    sorting: {
    enabled: true
    },
    behavior: {
    columnResizeMode: ‘split’
    },
    editing: {
    enabled: true,
    mode: ‘cell’
    },
    selection: {
    enabled: true,
    allowCellSelection: true,
    allowRowHeaderSelection: true,
    allowColumnHeaderSelection: true,
    mode: ‘extended’
    },
    filtering: {
    enabled: true,
    filterMenu: {
    mode: ‘excel’
    }
    },
    dataSource: new Smart.DataAdapter(
    {
    dataSource: data,
    dataFields:
    [
    ‘val1: number’,
    ‘desc: string’,
    ‘init: string’,
    ‘cat: string’,
    ]
    }),
    layout: {
    rowHeight: 15
    },
    columns: [
    { label: ‘cod’, dataField: ‘val1’ , visible: false},
    { label: ‘desc’, dataField: ‘desc’, allowEdit: false, width:450,},
    { label: ‘init’, dataField: ‘init’,width:150, template: function(formatObject) {
    var cat= formatObject.row.data[‘cat’];
    var desc=formatObject.row.data[‘desc’];
    if (sel==”122″){
    if (cat==”2″){
    formatObject.cell.background = “#eaed6e” //'<span style=”margin-right: 7px; padding: 4px 18px; border-radius: 10px 5px; color: blue; background: #eaed6e”>’ + formatObject.value + ‘</span>’
    }
    }
    if (sel==”121″){
    if (cat==”3″){
    formatObject.cell.background = “#eaed6e” //'<span style=”margin-right: 7px; padding: 4px 18px; border-radius: 10px 5px; color: blue; background: #eaed6e”>’ + formatObject.value + ‘</span>’
    }
    }
    if (sel==”128″){
    if (cat==”4″){
    formatObject.cell.background = “#eaed6e”//'<span style=”margin-right: 7px; padding: 4px 18px; border-radius: 10px 5px; color: blue; background: #eaed6e”>’ + formatObject.value + ‘</span>’
    }
    }
    }
    },
    { label: ‘eee’, dataField: ‘cat’,width:150, visible: false}
    ]
    }
    }
    });

    Thanks in advance.

    #102897
    admin
    Keymaster

    Hi,

    I think that the formatFunction should be used instead here. Please, look at https://www.htmlelements.com/demos/grid/overview/

    Best regards,
    Peter Stoev

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.