JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Grid format cell
Tagged: datagrid format function
- This topic has 1 reply, 2 voices, and was last updated 2 years, 9 months ago by admin.
-
AuthorPosts
-
February 24, 2022 at 2:09 pm #102895ufficio.itParticipant
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.
February 24, 2022 at 11:02 pm #102897adminKeymasterHi,
I think that the formatFunction should be used instead here. Please, look at https://www.htmlelements.com/demos/grid/overview/
Best regards,
Peter StoevjQWidgets Team
https://www.jqwidgets.com/ -
AuthorPosts
- You must be logged in to reply to this topic.