Skip to content

Instantly share code, notes, and snippets.

@melaniecarr23
Created September 9, 2016 03:05
Show Gist options
  • Save melaniecarr23/e50a92e0de1c3d8ab6a1ae046b7c83d9 to your computer and use it in GitHub Desktop.
Save melaniecarr23/e50a92e0de1c3d8ab6a1ae046b7c83d9 to your computer and use it in GitHub Desktop.
PHP: Yii2 kartik dynagrid
<?= DynaGrid::widget([
'columns' => $columns,
'theme'=>'panel-info',
'showPersonalize'=>true,
'storage'=>'cookie',
'gridOptions'=>[
'pjax' => true,
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'floatHeader'=>true,
'options'=>['id'=>'grid-1'], // a unique gridID is important
'panel'=>[
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i>Appointments</h3>',
'before' => '<div style="padding-top: 7px;"><em>Healing happens above, down, inside out. Move the bone, doctor.</em></div>',
'after' => false
],
'toolbar' => [
['content'=>
Html::button('<i class="glyphicon glyphicon-plus"></i>', ['type'=>'button', 'title'=>'Add Book', 'class'=>'btn btn-success', 'onclick'=>'alert("This will launch the book creation form.\n\nDisabled for this demo!");']) . ' '.
Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['dynagrid-demo'], ['data-pjax'=>0, 'class' => 'btn btn-default', 'title'=>'Reset Grid'])
],
['content'=>'{dynagridFilter}{dynagridSort}{dynagrid}'],
'{export}',
]
],
'options'=>['id'=>'dynagrid-1'] // a unique identifier is important
]);
if (substr($dynagrid->theme, 0, 6) == 'simple') {
$dynagrid->gridOptions['panel'] = false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment