1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    6
    Vote Rating
    0
    entropia is on a distinguished road

      0  

    Default Unanswered: how to load data with ?select=field1,field2 options using rest

    Unanswered: how to load data with ?select=field1,field2 options using rest


    Hello!..

    There is model with many fields.

    Code:
    Ext.define('GksksAisk.model.Client', {
        extend: 'Ext.data.Model',
        idProperty: 'clientId',
        fields: [
            { name: 'clientId',                mapping: 'client_id',                 type: 'int',        useNull: true,          disabled: false,   submitValue: false },
            { name: 'clientName',              mapping: 'client_name',               type: 'string' },
            { name: 'clientChairman',          mapping: 'client_chairman',           type: 'string' },
            { name: 'clientChiefAccountant',   mapping: 'client_chief_accountant',   type: 'string' },
            { name: 'clientContractNumber',    mapping: 'client_contract_number',    type: 'string' },
            { name: 'clientContractIndex',     mapping: 'client_contract_index',     type: 'string' },
            { name: 'clientContractDate',      mapping: 'client_contract_date',      type: 'date',       dateFormat: 'Y-m-d'},
            { name: 'clientContact',           mapping: 'client_contact',            type: 'string' },
            { name: 'clientCommission',        mapping: 'client_commission',         type: 'float',      useNull: true },
            { name: 'clientDebt',              mapping: 'client_debt',               type: 'float',      useNull: true },
            { name: 'clientComments',          mapping: 'client_comments',           type: 'string' },
            { name: 'clientManager',           mapping: 'client_manager',            type: 'string' },
            { name: 'clientActive',            mapping: 'client_active',             type: 'bool' }
        ],
    
    
        proxy: {
            type: 'rest',
            url: '/api/clients',
            reader: {
                type: 'json',
                root: 'children',
                successProperty: 'success'
            },
            writer: {
                type: 'json',
                writeAllFields: false
            }
        }
    });
    clientComments field may contain very big block of text so i try to avoid load this field if it is not used in my grid

    I don't inderstand how to send request with ?select=client_id,client_name,client_active (or any another format) when store loads.

    if i will just copy proxy to each store and change url to /api/clients?select=client_id,client_name,client_active - extjs will use this url with create, update and destroy requests, this not good...

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,604
    Answers
    543
    Vote Rating
    325
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Take a look at:

    http://docs.sencha.com/ext-js/4-0/#!...d-buildRequest
    http://docs.sencha.com/ext-js/4-0/so...d-buildRequest

    You've got a choice of methods in there you could override to customize the parameters however you see fit.

Thread Participants: 1