如何基于json数据extjs设置radiogroup radiofield 4 [英] how to set radiogroup radiofield based on the json data extjs 4

查看:205
本文介绍了如何基于json数据extjs设置radiogroup radiofield 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

论坛成员,我在extjs 4中设置无线电场时遇到了一个问题

hi forum member I am having one problem with setting the radiofield in the extjs 4

我的表单无线电组xtype代码在下面给出

{
  xtype: 'radiogroup',
  dataIndex: 'gender',
  margin: 5,
  fieldLabel: 'Gender',
  items: [{
    xtype: 'radiofield',
    name: 'gender',
    boxLabel: 'Male',
    inputValue:'0'
  }, {
    xtype: 'radiofield',
    name: 'gender',
    boxLabel: 'Female',
    inputValue:'1'
  }]
}

我正在接收的json数据

{
  "total": 1,
  "success": true,
  "employeedata": [{
     "username": "yaryan997",
     "surname": "Singh",        
     "firstname": "Yogendra",
     "gender": false
  }]
}

我的员工列表视图具有操作列editEmployee,它执行以下功能

editEmployee:function(grid,no,rowindex,colindex,temp) {
        alert('Edit EMPLOYEE button pressed');
        var rec = grid.store.getAt(rowindex);
        var employeeid = rec.get('id');

        store = grid.getStore();
        store.load({
            params: {'employeeid':employeeid},
            scope: this,
            callback: function(records, operation, success) {
                //the operation object contains all of the details of the load operation
                console.log(records);
                this.getEmployeeEdit().editform=1;
                this.getEmployeeEditForm().loadRecord(rec);                 
                this.getEmployeeEdit().show();
            }
        });
        this.getEmployeeStore().load();
    },

基于显示editEmployee视图的ID.我的编辑Employee正确显示了所有值,但是唯一的问题是无线电场.他们没有显示所选的值.

based on the id the editEmployee view is shown. My edit Employee shows all the values correctly but only the problem is with the radiofield. They didn't show the selected value.

我为您提供的我的json数据(作为employeedata出现)

我无法根据我从json接收的数据来设置广播组的性别.

I am not able to set the radiogroup gender based on the data i am receiving from the json.

请给我一些解决方案.

推荐答案

首先,您应将inputValue设置为'false'和'true'.第二个是无线电组的新设计.您可以在sencha论坛的线程中找到解决方案,请参见:

First you should set inputValue to 'false' and 'true'. The second is the new design of a radiogroup. You will find the solution in my thread at the sencha forum See: http://www.sencha.com/forum/showthread.php?187185-Set-a-int-value-on-a-radiogroup-fails&goto=newpost

问题在于,setValue期望有一个对象,只有在必须为性别设置数据类型时才会如此.一个用于男性,一个用于女性...这就是为什么我将其发布为bug的关键所在.从我的帖子中覆盖替代代码.

The problem is that setValue is expecting a object which would only be the case if you had to datatypes for gender; one for male and one for female... And that's the point why I posted this as bug. Down the override code from my post.

setValue: function (value) {
    if (!Ext.isObject(value)) {
        var obj = new Object();
        obj[this.name] = value;
        value = obj;
    }
    Ext.form.RadioGroup.prototype.setValue.call(this, value);
}  

这篇关于如何基于json数据extjs设置radiogroup radiofield 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆