http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Types-property-DATE ओह हे एक तारीख डेटा प्रकार ...
वैसे भी, आपके सवाल का जवाब देने से पहले! (Tl देखते हैं; एक तारीख डेटा प्रकार उदाहरण के लिए डॉ)
http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Field-cfg-convert
एक समारोह है जो एक उद्देश्य यह है कि मॉडल में संग्रहीत किया जाएगा में रीडर द्वारा प्रदान की मूल्य बदल देता है। यह पारित हो जाता है निम्नलिखित मानकों:
वी: के रूप में, रीडर द्वारा पढ़ा करता है, तो अपरिभाषित कॉन्फ़िगर किया गया DefaultValue का उपयोग करेगा मिश्रित
डेटा मान। आरईसी: Ext.data।मॉडल
डेटा ऑब्जेक्ट जिसमें पाठक द्वारा अब तक पढ़ा गया है। ध्यान दें कि इस बिंदु पर मॉडल पूरी तरह से पॉप्युलेट नहीं हो सकता है क्योंकि फ़ील्ड को आपके फ़ील्ड सरणी में परिभाषित करने के क्रम में पढ़ा जाता है।
Ext.define('Dude', {
extend: 'Ext.data.Model',
fields: [
{name: 'locationInCity', convert: function(rawDataValue,record){
return record.location+', '+record.city //would be something like Sprooklyn,Springfield
}},
{name: 'firstname', mapping: 'name.first'},
{name: 'lastname', mapping: 'name.last'},
{name: 'city', defaultValue: 'homeless'},
'state',
{name: 'location', convert: location}
]
});
आह और इस बिंदु पर मैं अपने उदाहरण का स्रोत पाया;)
// Add a new Field data type which stores a VELatLong object in the Record.
Ext.data.Types.VELATLONG = {
convert: function(v, data) { // convert(value,record)
return new VELatLong(data.lat, data.long); //VELatLong was declared previously in another library as something according to example
},
sortType: function(v) {
return v.Latitude; // When sorting, order by latitude //VELatLong will have lat and long properties, this is for complex sorting
},
type: 'VELatLong' //This is what we use to reference it.
};
सभी इस करता है और अधिक या कम एक नया डेटा प्रकार की घोषणा है। यह
// Add a new Field data type which stores a VELatLong object in the Record.
Ext.data.Types.tehDate = {
convert: function(v, data) { // convert(value,record)
return new date(v);
},
sortType: function(v) {
return v; // eh i have no idea whether its going to actually just accept date comparisons, though no there's real reason why it shouldn't
},
type: 'tehDate' //This is what we use to reference it.
};
^-- some of this is untested.
टीएल कुछ ऐसा दिखाई देगा; डॉ
अब वास्तव में अपने -original- सवाल का जवाब देने:
Ext करता दिनांक प्रकार आप उपयोग कर सकते हैं: Ext.data.Types .DATE (साथ ही कुछ अन्य)।
मुझे लगता है कि प्रकार: दिनांक काम नहीं किया, अन्यथा हम यहां नहीं होंगे! तो शायद केवल 4 को ठीक से संदर्भित किया जाता है। लेकिन! यह करता है काम:
var types = Ext.data.Types; // allow shorthand type access
Ext.define('Unit', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'dated', type: types.DATE },
{ name: 'pie', type: 'string' },
]
}
});
abc=Ext.create('Unit',{
dated: new Date().toString(),
pie:'hello'
})
console.log(abc)
console.log(abc.get('dated').getUTCFullYear())//it liiiiives!
काम कर कोड के फिडल:
http://www.senchafiddle.com/#w97Oe
मैं इस पर आगे काम करूंगा। उम्मीद है कि अगले कुछ दिनों में आपके लिए एक जवाब होगा। रहो रहें :) –