view app/model/Kommentar.js @ 130:747d488b9203

Added function getEidi which returns the part of the id of an item which needs to be appended to the store base URL for PUT and DELETE and GET Requests. This function is used to build a custom id. On default it returns the value of getId.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 25 Jun 2013 17:29:17 +0200
parents 84f32c62670f
children 7b1140bd8b3d
line wrap: on
line source
Ext.define('Lada.model.Kommentar', {
    extend: 'Ext.data.Model',
    fields: [
        {name: "id"},
        {name: "kid", mapping:"id.kid"},
        {name: "convertedId", convert:buildId},
        {name: "probeId"},
        {name: "erzeuger"},
        {name: "kdatum", type: 'date', convert: ts2date, defaultValue: new Date()},
        {name: "ktext"}
    ],
    idProperty: "convertedId",
    proxy: {
        type: 'rest',
        appendId: true, //default
        url: 'server/rest/kommentare',
        reader: {
            type: 'json',
            root: 'data'
        }
    }
});

function buildId(v, record){
    return record.get('probeId') + record.get('kid');
}

function ts2date(v, record){
    // Converts a timestamp into a date object.
    return new Date(v);
}

http://lada.wald.intevation.org