2017-04-11 16 views
6

नीचे दिया गया कोड FullCalendar के Custom View दस्तावेज़ से है। यह एक महान शुरुआत की तरह लगता है, लेकिन मेरे जैसे किसी नए ब्रांड के लिए कुछ बुनियादी कोड होना बहुत उपयोगी होगा जो सबसे सरल कस्टम दृश्य (कुछ घटनाओं के साथ) प्रस्तुत करता है। वे आपको संदर्भ के रूप में BasicView और AgendaView को देखने के लिए कहते हैं, लेकिन यह मेरी समझ से थोड़ा सा है। कस्टम वर्ग में प्रत्येक कार्य को ओवरराइड करने की आवश्यकता है?बुनियादी फुल कैलेंडर कस्टम व्यू कैसे बनाएं

इस प्लंकर के पास एक कस्टम पूर्ण कैलेंडर में बदलने के लिए एक मूल पूर्ण कैलेंडर और एक बटन है। एक कामकाजी उदाहरण देखना बहुत उपयोगी होगा। मैं कस्टम व्यू के लिए सफलता के बिना घंटों तक टंकण कर रहा हूं। यदि आप फुल कैलेंडर जानते हैं और कार्यों के लिए कुछ कोड भरने के इच्छुक होंगे तो इसकी बहुत सराहना की जाएगी!

https://plnkr.co/edit/gfEUCVYTWTm1md24e33m?p=preview

मेरा लक्ष्य एक दिन में सूची है कि एक स्क्रॉल div (जहां प्रत्येक प्रविष्टि अंत में काफी डेटा और सीएसएस स्टाइल के साथ बाहर fleshed किया जाएगा क्रम में दिन के सभी ईवेंट सूचीबद्ध निर्माण करने के लिए है - मैं सुनिश्चित नहीं है कि क्या सूची इस प्रकार के अनुकूलन की अनुमति देगी ??)।

var FC = $.fullCalendar; // a reference to FullCalendar's root namespace 
var View = FC.View;  // the class that all views must inherit from 
var CustomView;   // our subclass 

CustomView = View.extend({ // make a subclass of View 

    initialize: function() { 
     // called once when the view is instantiated, when the user switches to the view. 
     // initialize member variables or do other setup tasks. 
    }, 

    render: function() { 
     // responsible for displaying the skeleton of the view within the already-defined 
     // this.el, a jQuery element. 
    }, 

    setHeight: function(height, isAuto) { 
     // responsible for adjusting the pixel-height of the view. if isAuto is true, the 
     // view may be its natural height, and `height` becomes merely a suggestion. 
    }, 

    renderEvents: function(events) { 
     // reponsible for rendering the given Event Objects 
    }, 

    destroyEvents: function() { 
     // responsible for undoing everything in renderEvents 
    }, 

    renderSelection: function(range) { 
     // accepts a {start,end} object made of Moments, and must render the selection 
    }, 

    destroySelection: function() { 
     // responsible for undoing everything in renderSelection 
    } 

}); 

उत्तर

1

मैंने कस्टम दृश्य कार्य करने के लिए आपके प्लंकर में कुछ पंक्तियां जोड़ दी हैं। https://plnkr.co/edit/8iOq15CsL2x6RPt29wgE?p=preview

बस परिवर्तन का उल्लेख: आप यहाँ उदाहरण मिल सकते हैं कैलेंडर में प्रारंभकर्ता दृश्य परिभाषा

$('#calendar').fullCalendar({ 
... 
    views: { 
      CustomView: { 
       type: 'custom', 
       buttonText: 'my Custom View', 
       click: $('#calendar').fullCalendar('changeView', 'CustomView') 
      } 
     } 
}); 

जोड़ दिया गया है बस में यह जोड़ा कस्टम दृश्य में प्रस्तुत करना

$('.fc-view').append("<div>Insert your content here</div").css("background", "red"); 

var myEvents=$('#calendar').fullCalendar('clientEvents'); 
0123:

कस्टम में आप ऐसा करने से घटनाओं के लिए पहुँच जाते हैं देखने

वहां से आप अपने और अनुकूलन कर सकते हैं

संबंधित मुद्दे