philippfrenzel / yii2fullcalendar

JQuery Fullcalendar Yii2 Extension
GNU General Public License v2.0
132 stars 95 forks source link

Event not rendering from Ajax #39

Closed djkumar closed 8 years ago

djkumar commented 8 years ago

Hey Philip, I've been using this extension for my project, I can create the event on the weekview design, But i can't able to retrieve the stored events from the database. Here is the sample ajax returned value. Can give a suggestion on this

11

philippfrenzel commented 8 years ago

hmm, the initial data doesn't seem that wrong - it looks like you have all mandantory fields available... Here is a sample code that works for me: `` <?php /* * Renders the activities inside a calendar... might be nicer to view * @param [type] $start [description] * @param [type] $end [description] * @param [type] $_ [description] * @return [type] [description] / public function actionJsoncalendar($start=NULL,$end=NULL,$entity=NULL,$entityid=NULL,$=NULL, $entityTitleField = NULL){ \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

    if($start = null)
    {
        $startObj = new DateTime();
        $start = $startObj->format('U');
    }

    $events = Activity::getCalendarActivities($start,$end,$entity,$entity_id, $entityTitleField);
    return $events;
}

?> ``

and within calendar

<?php yii2fullcalendar\yii2fullcalendar::widget([ 'options' => [ 'lang' => substr(\Yii::$app->language,0,2), 'class' => 'fullcalendar' ], 'header' => [ 'left' => 'prev', 'center' => 'title', 'right' => 'next' ], 'clientOptions' => [ 'defaultView' => 'month', 'height' => 450, 'selectable' => true, 'selectHelper' => true, 'defaultDate' => date('Y-m-d'), 'eventClick' => new JsExpression($JSEventClick), 'eventLimit' => true ], 'ajaxEvents' => Url::toRoute(['/activity/default/jsoncalendar','entity' => $entity, 'entityTitleField' => $entityTitleField]) ]); ?>

djkumar commented 8 years ago

Hey Thanks much. It got working.