需要有关匿名ID问题的帮助

时间:2011-08-17 14:55:00

标签: ruby-on-rails extjs

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"
}];

问题如下:

我有桌子(正如你所看到的)..如果被访者回答并且他把旗帜推给(我提出匿名)然后(在我的版本中)respondent_id获得0作为id并且在故事的受访者中有用户一些id称为匿名,然后在extjs我看到 - 匿名(来自respondent_id)。

这有效,但还有另外一种方法..将字段is_anonymous添加到查询表中(答案与答复者表之间的关系)。但是在列电子邮件中的answers_json获取有关answer.respondent.email的信息...如何只使用添加字段is_annonymous来做另一种方式(如果是= 1,如果没有= 0)。这很聪明。但它如何写在extJS?功能?以及如何?

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用convert:作为字段定义的一部分。查看当前值并将其替换为您喜欢的值。

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