我正在使用带有DateRangePicker的Kartik GridView。我在GridView工具栏部分中按如下所示初始化DataRangePicker
<?= GridView::widget([
'id' => 'jsp-grid',
'toolbar'=> [
['content'=> $toolbar_content],
$toolbar_datarange,
'{export}',
],
..和实际的DateRangePicker:
$addon = '
<div class="input-group-append">
<span class="input-group-text">
<i class="fas fa-calendar-alt"></i>
</span>
</div>';
$separator = ' - ';
$toolbar_datarange = '<div class="input-group drp-container">' .
DateRangePicker::widget([
'name' => 'date_range_jsp',
'value' => $drf . $separator . $drt,
'useWithAddon' => true,
'convertFormat' => true,
'presetDropdown' => false,
'language' => 'fi',
'hideInput' => true,
'pluginEvents' => [
"apply.daterangepicker" => "function(ev, picker) { getDataRange(picker.startDate.format('YYYY-MM-DD'), picker.endDate.format('YYYY-MM-DD')); }",
],
]) . $addon . '</div>';
DateRangePicker将显示在GridView的“内部”(即在标题中)。
问题是,当切换到HTML:同一视图的命令“ Lukossa”或“ Kesken”时,出现以下错误:
Html::a(Yii::t('app', 'Lukossa'), [CONTROLLER_ACTION_INDEX, '_tog' => SEALED_ORDER_STATUS_LOCKED]);
Html::a(Yii::t('app', 'Kesken'), [CONTROLLER_ACTION_INDEX, '_tog' => SEALED_ORDER_STATUS_NOTDONE]);
实际错误是:
VM23220:5 Uncaught ReferenceError: kvSelectRow is not defined
at HTMLDivElement.eval (eval at globalEval (jquery.js:343), <anonymous>:5:100)
at HTMLDivElement.dispatch (jquery.js:4737)
at HTMLDivElement.elemData.handle (jquery.js:4549)
at Object.trigger (jquery.js:7807)
at HTMLDivElement.<anonymous> (jquery.js:7875)
at Function.each (jquery.js:365)
at jQuery.fn.init.each (jquery.js:137)
at jQuery.fn.init.trigger (jquery.js:7874)
at fire (jquery.pjax.js:217)
at jQuery.fn.init.options.complete (jquery.pjax.js:262)
在此代码行上发生(Kartik GridView):
jQuery("#jsp-pjax-wrapper").off('pjax:complete.573d5ab1').on('pjax:complete.573d5ab1', function(){ kvSelectRow('jsp-grid', 'info');
为什么会发生这种情况?谢谢。