I'm looking for the best way to define own custom type in ExtJs. I would like to use it in forms, grids, pivots, etc., it should has own rendering, calculating and sorting behaviour.
Consider a type 'pace'. Pace is defined as amount of time needed to move on unit of distance, for example pace 2:30 means you need two and half minute to do 1 mile or km. Pace could be added (2:30 + 2:35 = 5:05) and be used in other calculations. The smaller pace is faster, that means pace 2:00 is faster (higher) than 2:30.
So far as I know, this is a way to define own custom type and use it in data model as in coding below:
Ext.define('App.fields.Pace', {
extend: 'Ext.data.field.Field',
alias: 'data.field.pace'
});
Ext.define( 'Data', {
extend: 'Ext.data.Model',
fields: [
{name: 'id'},
{name: 'pace', type: 'pace'}
]
});
Such defined type is a dummy one, it doesn't render, sort or calculate correctly.
Is there a way to extend it, so it will work ok in forms, grids, pivots, etc.? What should I do to archive it? Should I define or overwrite some methods? Or perhaps I should take other similar type (for example date) and inherit it or use it as template? I think as minimum the new custom type should provide a method to convert its value to internal type like int and a method to render this internal value as external format but I haven’t find such methods.
Is it possible to define own type which will work correctly in all scenarios where standard type could be used?
Regards, Annie