Kartik Gridview responsive column headers - yii

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

Related

Yii thumbnail on focus enlarge

I have given a Thumbnail view to my page which is an extended widget of bootstrap want to make it onclick enlarge or onclick thumbnail image change. How may I set those two options in my widgets. I searched, but couldn't get the right one.
$this->widget(
'bootstrap.widgets.TbThumbnails',
array(
'dataProvider' => $dataProvider,
'template' => "{items}\n{pager}",
'itemView' => '_thumb',
) );
where the _thumb is my view file(php file).
With this widget you can't. It is for creating a list of thumbnails. If you want to enlarge them in eg a lightbox you have to install a lightbox extension and make it work with this thumbnails. It's the same for changing the images onclick.

How to remove Label for attribute from checkBoxList in yii

$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.

How can I make a tooltip link to another page?

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. :))

PHPExcel white background

I am importing an Excel spreadsheet into a web page using the PHPExcel libraries:
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
it works but it overrides my page background to white. Every other element on the page it's formatted correctly according to my CSS but not the background. Any idea?
The default background for an Excel cell is white, so you probably want to change that. I don't know where you're setting the page background in the first place, unless you've modified the HTML Writer to do so, or changed it in the Excel file (you don't indicate which); but try setting a default cell background for the worksheet:
$objPHPExcel->getDefaultStyle()->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'FFFFFF00')
),
)
);
Mark Baker point me in the right direction to answer my own question, this is the reason why I marked his answer as the accepted one.
To fix my problem I have added the following lines:
$objWriter->generateStyles(false);
echo $objWriter->generateSheetData();
after:
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');

Yii bootstrap grid: Trying to get property of non-object

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