I am using gridview/Dynagrid widget,and having approximatly 60 columns in it. it looks bad to see all columns at a time. Is there any widget or way to show/hide columns dynamically??
thanks in advance!!
here is code
index.php
echo DynaGrid::widget([
'columns' => $gridColumns,//I have 60 columns in $gridcolumn, requirement is to show/hide column dynamically
'storage'=>DynaGrid::TYPE_COOKIE,
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
],
'options'=>['id'=>'dynagrid-1']
]);
?>
first, you will download Yii2-DynamicForm
php composer.phar require --prefer-dist wbraganca/yii2-dynamicform "*"
secend this two videos will help you
part 1
https://www.youtube.com/watch?v=qqFpTBr323Y
part 2
https://www.youtube.com/watch?v=eAg0LIrZDdk
Here is another option: DynaGrid
Related
is there any way to hide PAGE param in Yii2 pagination listview?
current is domain/(anyattribute)?page=2
output should be domain/(anyattribute)/2
I don't think you can hide it. If you want to hide all of your param attributes then it is possible.
Pjax::begin(['enablePushState' => false]);
//your grid
Pjax::end();
Take a look on https://yii2-cookbook.readthedocs.io/pagination-pretty-urls/
It should solve your problem.
I am trying to create a Yii2 theme, & would like to set a variable that with scope of the entire views folder. For a single page theme I used...
$assetDir = Yii::$app->assetManager->getPublishedUrl(
'#vendor/path/to/assets/folder'
);
in index.php & I then I accessed it using...
<img src="<?= $assetDir ?>/img/image.jpg" alt="">
For partials I am able to pass that using...
<?= $this->render('_partial.php', ['assetDir' => $assetDir]) ?>
I am now wanting to do similar in a theme with multiple pages & cannot find how to do that without setting $assetDir in each page. I imagine it would be set in the main.php layout.
Use params array for this as stated in Sharing Data among Views.
The view component provides the params property that you can use to share data among views.
For example, in an about view, you can have the following code which specifies the current segment of the breadcrumbs.
$this->params['breadcrumbs'][] = 'About Us';
Then, in the layout file, which is also a view, you can display the breadcrumbs using the data passed along params:
<?= yii\widgets\Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
I have a template that i was using for my project.
Look at the picture below:
This is when i am not using the kartikGrid. the dropdown menu running as well as the template want.
look at the image below:
this is when i use kartik, the dropdown menu not running anymore.
can some body tell me why it happen.
The template using different bootsrap version with kartik.
thaks.
Hope some body help me.
Imaginaroom, that did the trick for me thank you.
My top menu wasn't responding (direct link, or drop down menu) after kartik was used. I added an id to my menu widget and it did the trick.
echo Nav::widget([
'id' => 'topMenuID',
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
Manually assign different ids to all widgets, so there won't be any conflicts.
If you don't assign ids to widgets, yii gives them one automatically, but the problem occures when loading data with ajax or pjax, then Yii cannot know which ids are already used in the page.
Every widget in Yii2 has a property 'id' that you can assign in configuration array when calling a widget.
Add this code in layout or page that has problem:
$this->registerJs( "$(document).ready(function() { $('.dropdown-toggle').dropdown(); });", View::POS_END, 'ecommerceProductJs' );
I am updating my portfolio website and require a different sidebar for different ties of pages, i.e. one for work page and one for the blog page, apparently this can be done using Custom Fields in the page or post.
So, I opened up single.php and found the following code
<?php get_sidebar(); ?>
And replaced it with the code below
<?php $sidebar = get_post_meta($post->ID, "sidebar", true);
get_sidebar($sidebar);
?>
To add a custom sidebar, all I need to do now is apparently add the custom field “Sidebar” and include the name of the sidebar file. For example if I insert “page-01”, it will display sidebar-page-01.php as your sidebar.
After multiple times of trying however this 'isn't' the case, can't see anything wrong with what I am doing, any one have any ideas? Any help would be greatly appreciated!
Thanks guys!
You can do this the way you are doing it by doing your own php function and target the page you need with
<?php
if ( is_home() ) :
get_sidebar( 'home' );
elseif ( is_portfolio page1() ) :
get_sidebar( 'portfolio page sidebar' );
else :
get_sidebar();
endif;
?>
add more elseif statements for as many page & sidebar combination you will have
or you can download this plugin and use the code above the same way
I am using wordpress multisite for 5 websites. I created a child theme off of the parent so all sites have the same theme, but we have a need for slightly different introduction text at the top of the home pages.
The theme I am using has 3 columns but only has widget-able functionality in column 2 and 3, but the main content area does not have a widget area. Otherwise i would have dropped in a text widget for what i want here.
My question is what is the best way to add this text?
1.) Would I do this in functions.txt? Something like if(site1) echo, elsif(site2) echo, or is there an easier way than this?
2.) Is there a way to do this by editing the theme files and using some short of shortcode? But then where would i define what text to place in there based on the site thats loading?
Please provide a simple example in code if possible. Thanks in advance!
step 1, add to your function.php
<?php
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Column 1',
'id' => 'column_1',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
step 2, now you will find the widget area in your dashboard Appearance/Widgets, add your content to it.
step 3 add <?php dynamic_sidebar( 'column_1' ); ?> in your template where you want to have column 1
Beside coding the theme there are also other way maybe easier ...
Use this plugin to create widget zone inside a page:
Widgets on Pages
Versione 0.0.12 | by Todd Halfpenny
Use this plugin so you can display or not the widget deending on what page you are:
Dynamic Widgets
Versione 1.5.6 | by Qurl