开发者

Need help with problem with anonymous ids

开发者 https://www.devze.com 2023-03-28 13:53 出处:网络
i have: var answers_json = [{ name: \"email\", mapping: \"answer.respondent.email\" }, { name: \"group\", mapping: \"answer.respondent.respondent_group_id\"
i have:

var answers_json = [{
    name: "email",
    mapping: "answer.respondent.email"
}, {
    name: "group",
    mapping: "answer.respondent.respondent_group_id"
}, {
    name: "text",
    mapping: "answer.text"
}, {
    name: "scale",
    mapping: "answer.scale"
}, {
    name: "created_at",
    mapping: "answer.created_at",
    type: "date",
    dateFormat: "c"
}];


var answers_columns = [{
    id: "email",
    header: a_email,
    width: 240,
    sortable: true,
    resizable: false,
    menuDisabled: true,
    dataIndex: "email",
    //renderer: anonim_fun i need to write function?
}, {
    id: "group",
    header: "<div style=text-align:center>" + a_group + "</div>",
    width: 55,
    sortable: true,
    resizable: false,
    menuDisabled: true,
    dataIndex:开发者_运维知识库 "group"
}, {
    id: "text",
    header: a_answer,
    width: 550,
    sortable: true,
    resizable: false,
    menuDisabled: true,
    dataIndex: "text"
}, {
    id: "scale",
    header: a_scale,
    width: 50,
    sortable: true,
    resizable: false,
    menuDisabled: true,
    dataIndex: "scale"
}, {
    id: "created_at",
    header: a_added_date,
    width: 120,
    sortable: true,
    resizable: false,
    menuDisabled: true,
    dataIndex: "created_at",
    xtype: "datecolumn",
    format: "Y-m-d H:i:s"
}];

Problem is follow:

I have tables (as you can see) ..if respondent answered and he putted flag to (I ASK ANONYMOUS) then (IN MY VERSION) respondent_id gets 0 as id and in tale respondents there are user with some id called anonymous and then in extjs i see - anonymous (from respondent_id).

This works, but there are another way.. add field is_anonymous into inquiry table (relation between answers & respondents tables). but answers_json in column email get info about answer.respondent.email... How i can do another way with just adding field is_annonymous (and if yes = 1, if no = 0). this is much clever. But how it write in extJS? Function? AND HOW?

thanks!


You can use convert: as part of your field definition. Look at the current value and replace it with what you prefer.

{
    name: "email",
    mapping: "answer.respondent.email"
   convert: function(val) {
      if(val=="....") {
         return "(anonymous)"
   }
},
0

精彩评论

暂无评论...
验证码 换一张
取 消