How to capture data (extension)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jhosellrod
    Junior Member
    • Oct 2017
    • 1

    How to capture data (extension)?

    Hello guys, i'm new so i'm doing an extension and i want to capture data from options(like change() method from jquery) and parse it through client's controller, so i want to know the proper way to do this:

    client>modules>location>src>views>location>index.j s
    PHP Code:
    Espo.define('location:views/location/index', 'view', function (Dep) {
    return Dep.extend({
    template: 'location:location/index',
    setup: function() {
    Dep.prototype.setup.call(this);
    this.listenTo(this.model, 'change', function() {
    this.captureData();
    this.reRender();
    });
    },
    captureData: function() {
    console.log("captureData");
    }
    })
    }); 
    
    client>modules>location>src>controllers>location>l ocation.js
    PHP Code:
    Espo.define('location:controllers/location', 'controller', function (Dep) {
    return Dep.extend({     
    getSettingsModel: function () {
    var model = this.getConfig().clone();
    model.defs = this.getConfig().defs;
    return model;
    },
    index: function (options) {
    var model = this.getSettingsModel();
    this.main('location:views/location/index', {
    model: model
    });
    }
    });
    }); 
    
    this is de data i want to capture:
    application>espo>modules>location>resources>client Defs>location.json
    PHP Code:
    {
    "fields": {
    "map_canvas": {
    "type": "varchar"
    },
    "country": {
    "options": ["all", "country1", "country2"]
    },
    "type": {
    "options": ["all", "type1", "type2"]
    }
    }
    } 
    
    application>espo>modules>location>resources>layout s>detail.json
    PHP Code:
    [
    {
    "label":"Filter",
    "rows": [
    [
    {"name":"country","fullWidth": false},
    {"name":"type","fullWidth": false}
    ]
    ]
    },
    {
    "label":"Details",
    "rows": [
    [{"name":"data","fullWidth": true}]
    ]
    }
    ] 
    
    how do i create my template in client>modules>location>res>templates>location>ind ex.tpl ?
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    you can write any text in client>modules>location>res>templates>location>ind ex.tpl and check if everything is ok... open browser console and network tab
    layout s>detail.json this layout is not loaded

    this.listenTo(this.model, 'change', function() {
    this.captureData();
    this.reRender();
    }, this); //without 'this' captureData and reRender be unreachable


    If you need default entity, the easiest way is to create needed entity with Entity Manager on other instance and move file to and your module with some modification

    Find the closest entity you need in basic version and use it as example

    Comment

    Working...