This:
$gridDataProvider = new CArrayDataProvider(array(
array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
array('id'=>2, 'firstName'=>'Jacob', 'lastName'=>'Thornton', 'language'=>'JavaScript'),
array('id'=>3, 'firstName'=>'Stu', 'lastName'=>'Dent', 'language'=>'HTML'),
));
$this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>array(
array('name'=>'id', 'header'=>'#'),
array('name'=>'firstName', 'header'=>'First name'),
array('name'=>'lastName', 'header'=>'Last name'),
array('name'=>'language', 'header'=>'Language'),
array(
'class'=>'bootstrap.widgets.BootButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
),
));
is returning:
Trying to get property of non-object
Menu, buttons (and everything else) works fine.
This hapens because the example uses CArrayDataProvider to populate the grid.
When you get inside BootButton (the class that generates this column) to see what runs through it, you will see that it is trying to get the primaryKey property from dataprovider, but there is no such property, as the data is of array type.
You have to pass a CActiveDataProvider for your grid, if you plan to use buttons with it.
So try to use like this:
$this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>$model->search(),
'template'=>"{items}{pager}",
'filter'=>$model,...
Where $model is a CActiveRecord passed to the view by your controller.
I don't know what is the code you got in this class -- bootstrap.widgets.BootButtonColumn
But whatever it is, this is a what is causing the issue.
Make sure you have the full action of each button defined, in order to avoid this issue.
what I mean is, for every button in the button column set the url as --
'$this->grid->controller->createUrl("action_name", array("param_name" => "param_value"))'
this should solve the problem.
It's caused by the Button Column missing variables
It should be
array(
'class'=>'bootstrap.widgets.BootButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
'viewButtonUrl'=>null,
'updateButtonUrl'=>null,
'deleteButtonUrl'=>null,
),
//reposted from here
Related
In Kartik Gridview is there a way I can move the Column Headers and Column Search Fields so they are next to each other than stacked like this when when on an Iphone etc.
I want it to show FAQ Type - Question - Answer all on one line when I am see this on a Iphone 6 screen
Try this:
'responsive'=>true,
Your gridview:
use kartik\grid\GridView;
// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget([
'dataProvider'=> $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'responsive'=>true,
'hover'=>true
]);
Refrence
$records_skincolor1 = array('Black'=> 'Black','Brown'=> 'Brown','Dark Brown'=> 'Dark Brown','Blue'=> 'Blue','Grey Blue'=> 'Grey Blue','Hazel'=> 'Hazel','True Green'=> 'True Green');
echo CHtml::checkBoxList('Superadvancesearch[talent_skincolor][]','',$records_skincolor1, array(
'template'=><li>{input}{label}</li>,
'separator'=>'',
));
I need to remove label for attribute. How to remove it.
If you use Yii 1.1.14 you can use the new beginLabel, labelTitle and endLabel placeholder. In this case, no for will be rendered:
'template' => '{input}{beginLabel}{labelTitle}{endLabel}'
But to be honest I can hardly see a reason why you would want to remove this attribute. Because then you can't click the label anymore to check/uncheck a checkbox. Maybe your rather look for surrounding labels:
'template' => '{beginLabel}{input}{labelTitle}{endLabel}'
This is how Bootstrap expects checkboxes and here the label can still be clicked to check/uncheck the checkbox.
The same works for radiobuttons, too, BTW.
you can do this:
you are giving an array to your CHtml::checkBoxList method.
you just define the array before this method and make it with your condition.
if ($value == $someValue)
$yourArray=array(
'template'=><li>{input}{label}</li>,
'separator'=>'',);
else
$yourArray=array(
'template'=><li>{input}</li>,
'separator'=>'',);
and give this to your method:
echo CHtml::checkBoxList('Superadvancesearch[talent_skincolor][]','',$records_skincolor1, $yourArray
));
cheers.
In the data gridview, I am able to put tooltip (http://yiibooster.clevertech.biz/javascript.html#tooltips) by using headerHtmlOptions and get the data from the database.
My problem is that I can't find a way to put a link in the tooltip. For example, "This is tooltip. See more.." If 'See more..' is clicked it should go to another page. Thanks.
Try this with changes of your script!
array(
'header'=>'Video Url',
'name' => 'video_url',
//'value' => 'CHtml::link($data->title,$data->video_url, array("target"=>"_blank"))',
'value' => 'CHtml::link("View Video", $data->video_url, array("target"=>"_blank"))',
'type' => 'raw',
),
Perhaps you are missing target_blank
I have found this extension (http://www.yiiframework.com/extension/tooltipster/) and it works the way i want. It made possible for me to have a tooltip with link. :))
'items'=>array(
array(
'label'=>'About',
'url'=>array('about/index')
),
about/index - we get the class on the menu - active.
about/graphic - we don't get the class on the menu active.
about/print - we don't get the class on the menu active.
Please note that the menu has NO subitems.
Only About.
No mater if the user is on graphic, print or whatever, we wish to have the About highlighted.
How can we accomplish this ?
I've tried to edit that 'url' param a lot. No luck.
'items'=>array(
array(
'label'=>'About',
'url'=>array('about/index'),
'active'=>Yii::app()->controller->id=='about',
),
Added the active param. This worked.
active: boolean, optional, whether this menu item is in active state
(currently selected). If a menu item is active and activeClass is not
empty, its CSS class will be appended with activeClass. If this option
is not set, the menu item will be set active automatically when the
current request is triggered by url. Note that the GET parameters
not specified in the 'url' option will be ignored.
I've set that property. Otherwise it wouldn't work.
However, as you can see on the bold line, they say this should be automatically triggered. It wasn't on this case.
I suppose this was the case due to the fact that Yii is expecting a child element of About in order to apply that class, since there's any, we have to force it, to get the parent instead.
Not sure however.
CMenu is comparing item's route to current route, so by default it will work only for about/index.
I see two ways of forcing it - first is just set 'active' => true in items list:
$isActive = strpos(Yii::app()->controller->route, 'about/') === 0;
// ....
'items'=>array(
array(
'label'=>'About',
'url'=>array('about/index'),
'active' => $isActive
),
Or you can subclass CMenu class and overwrite CMenu::isItemActive($item,$route) method
simple but effective:
$action = Yii::app()->controller->action->id; // this is the action name currently running
'items'=>array(
array(
'label'=>'About',
'url'=>'/about/something',
'active'=>$action == 'something',
),
also...
to activate a menu, regardless of the action, just for a controller:
$controller = Yii::app()->controller->id; // this is the controller name
...
'active'=>$controller == 'something',
Notes:
add the $controller or $action variables, you can use them for more menu items. Your code will be cleaner.
you'll be 100% sure, the menu items will 'stick' active
I have this generated CListView code with some divs that I don't need.
I wish not to be absurd and hard code the class on zii/widgets.
I've seen this:
/**
* #var string the template to be used to control the layout of various components in the list view.
* These tokens are recognized: {summary}, {sorter}, {items} and {pager}. They will be replaced with the
* summary text, the sort links, the data item list, and the pager.
*/
public $template="{summary}\n{sorter}\n{items}\n{pager}";
It seems I can access $template and do something with it - can anyone please tell me, how can we remove the summary the sorter the items or the pager ?
Please advice.
Simply remove any of the {placeholder}s that you do not wish to render. To remove e.g. the sorter:
$this->widget('zii.widgets.CListView', array(
// set up CListView like you want, and then:
'template' => "{summary}\n{items}\n{pager}",
));