0
votes

I have a gridpanel with columns (months: june until december) in each cell of column I done a simple processing my problem if I make it in the converter (of the field of my model) it does not work :

var responses=record.responses();
var sum=0;
var nbResponses=0;
console.log('counts:'+responses.getCount()); 
for(var i=0;i<responses.getCount();++i){
  var response=responses.getAt(i);
  if(response.get('month')===0){
    sum+=response.get('score');
    ++nbResponses;
 }
}
var nb=Ext.Number.toFixed(sum/nbResponses,1);
if(isNaN(nb))
return '';
else return nb;

it always return '', I showed the responses.getCount() it will be 0, Now if I delete the converter and make this process in the renderer of the column it work and return me the correct value, my problem is if I let it in the renderer I can't access in this column for example (column 'jan') from another column because I have other column wish calculate the total of all month in the simple row so my grid panel is:

columns: jun|feb|..... |dec |total.
row1:    3  |  5|   000|   5|  13.

So you have any Idea and thanx. Thanx

1
Your question is a one big sentence. Could you please rephrase your question and insert some dots cause it's really hard to read it in its current form. - Molecular Man
Thanx for your reponse my freind, No problem I had changed my process. - Sayros

1 Answers

2
votes

A renderer is an 'interceptor' method which can be used to transform data (value, appearance, etc.) before it is rendered. It tells the grid how it should display the information on each cell of that column. Example:

{
    renderer: function(value){
       value?'<span style="color:green">TRUE</span>':'<span style="color:RED">FALSE</span>';
    }
}

A converter is a function which converts the value provided by the Reader into an object that will be stored in the Model. This function has access to "rows" of information inside your data store and can be used to create new fields in your data model that are a combinations of others. For example if you have a "First Name" and "Last Name" field, you can use convert to easily create a "Full Name" field.

None of those functions have access to the full length of the data store.

I hope it helps.