A
A
Adel1ne2016-06-29 14:38:02
ExtJS/Sencha
Adel1ne, 2016-06-29 14:38:02

How to display in Ext.grid.Panel the value of a field of a related table?

Hello! Started learning extJS and got stuck.
There are two tables:

Таблица users: с полями [
   id int, 
   login string, 
   id_status int (ссылается на поле id таблицы get_status)
Таблица get_status: с полями [
   id int, 
   status_name string

I need to display the fields in Ext.grid.Panel :
login from users and status_name from get_status corresponding id_status from users
From the guide I took the output in Ext.grid.Panel of one table
Model for the users table:
Ext.define('User', {
        extend: 'Ext.data.Model',

        idProperty: 'id',

        fields: [
            {
                name: 'id',
                type: 'int'
            },
            {
                name: 'login',
                type: 'string'
            } 
            {
                name: 'id_status',
                type: 'string'
            }
        ]
    });

Loading data:
var users = Ext.create('Ext.data.Store', {
        model: 'User',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'users.php',
            reader: {
                type: 'json',
                root: 'users'
            }
        }
    });

Output to Ext.grid.Panel:
Ext.create('Ext.grid.Panel', {
        title: 'Пользователи',
        height: 200,
        width: 600,
        store: users,
        columns: [
            {
                header: 'ИД',
                dataIndex: 'id'
            },
            {
                header: 'Логин',
                dataIndex: 'login'
            },
            {
                header: 'Статус',
                dataIndex: 'id_status'
            }
        ],
        renderTo: Ext.getBody()
    });

Tell me how to implement the display of related values ​​from the get_status table?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question