在GridField
我使用GridFieldEditableColumns
。內聯編輯正在運行,並在使用DateTimeField
時顯示日曆。SilverStripe 3 GridFieldEditableColumns DateField日曆
但是,當使用DateField
時,這不起作用。 (日曆不顯示)。有什麼我失蹤?
$holiDayConfig = GridFieldConfig_RecordEditor::create();
$holiDayConfig->removeComponentsByType('GridFieldDataColumns');
$holiDayConfig->removeComponentsByType('GridFieldAddNewButton');
$holiDayConfig->removeComponentsByType('GridFieldDetailForm');
$holiDayConfig->removeComponentsByType('GridFieldEditButton');
$holiDayConfig->addComponent(new GridFieldEditableColumns());
$holiDayConfig->addComponent(new GridFieldLayoutHelper());
$holiDayConfig->addComponent($newButton = new GridFieldAddNewInlineButton());
$newButton->setTitle(_t('OpenTimes.AddSchedule', 'add newSchedule'));
$holiDayGridfield = new GridField(_t('OpenTimes.SchedulesTab','Schedules/Holidays'), _t('OpenTimes.ScheduleTab','Schedule/Holidays'), $this->owner->HoliDays(), $holiDayConfig);
$holiDayConfig->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array(
'Schedule' => array(
'callback' => function ($record, $column, $holiDayGridfield){
$tPF = DateField::create('Schedule', 'AM'); // NOT WORKING
$tPF->setConfig('showcalendar', true); // NOT WORKING/NO CALENDAR
//$tPF = DateTimeField::create('Schedule', 'AM'); // WORKING
//$tPF->getDateField()->setConfig('showcalendar', true); // WORKING/SHOWING CALENDAR
return $tPF;
},
'title' => _t('OpenTimes.On', 'On')
)
)
));
我敢肯定有一個整潔自定義JavaScript的方式來做到這一點。在接下來的兩天裏,我沒有任何空閒時間,但在那之後,我有機會看看它,並分享我的想法。 – 3dgoo
:) ............. –
我添加了一個簡單的解決方案,將日期選擇器添加到可編輯網格字段列中的DateField。 – 3dgoo