jQuery UI Widgets › Forums › Grid › cell format
Tagged: cells format
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 9 years, 9 months ago.
-
Authorcell format Posts
-
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
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 StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.