I have setup CGridView with CArrayDataProvider
Controller
//Get data for form dropdown:
$criteria = new CDbCriteria;
$criteria->select = 'status';
$criteria->group = 'status';
$status_get = Model::model()->findAll($criteria);
foreach ($status_get as $s) {
$status[$s->status] = $s->status;
}
if(!isset($_GET['ajax'])){
//Display empty array - show no data before user input
$rawData=array();
} else {
// Here I want to be able to create custom array based on user input (from SQL query)
$rawData=array();
}
$arrayDataProvider=new CArrayDataProvider($rawData, array(
'id'=>'id',
/* 'sort'=>array(
'attributes'=>array(
'id', 'status',
),
), */
'pagination'=>array(
'pageSize'=>50,
),
));
$params =array(
'arrayDataProvider'=>$arrayDataProvider,
'status'=>$status,
);
if(!isset($_GET['ajax'])) $this->render('byDay', $params);
else $this->renderPartial('byDay', $params);
And View:
<?php
/* #var $this RaportController */
$this->breadcrumbs = array(
'Raport' => array('/raport'),
'ByDay',
);
?>
<h1><?php echo $this->id . '/' . $this->action->id; ?></h1>
<div class="form">
<?php $form = $this->beginWidget('CActiveForm', array(
'id' => 'person-form-edit_person-form',
'enableAjaxValidation' => false,
'htmlOptions' => array(
'onsubmit' => "return false;", /* Disable normal form submit */
'onkeypress' => " if(event.keyCode == 13){ send(); } " /* Do ajax call when user presses enter key */
),
)); ?>
<?php
if (isset($status)) {
echo CHtml::DropDownList('status', 'attribute', $status);
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'day',
'options' => array(
'showAnim' => 'fold',
'showOn' => 'both',
),
'htmlOptions' => array(
'style' => 'width:80px;vertical-align:top; margin-left:20px'
),
));
}
?>
<div class="row buttons">
<?php echo CHtml::Button('SUBMIT', array('onclick' => 'send();')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<script type="text/javascript">
function send() {
var data = $("form").serialize();
$.ajax({
type: 'POST',
url: '<?php echo Yii::app()->createAbsoluteUrl("raport/byDay"); ?>',
data: data,
success: function (data) {
},
error: function (data) { // if error occured
alert("Error occured.please try again");
alert(data);
}
// dataType:'html'
});
}
</script>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $arrayDataProvider,
'template' => "{items}",
'htmlOptions' => array(
'style' => 'margin:8px;'
),
'columns' => array(
array(
'name' => 'Order id',
'value' => 'CHtml::encode($data["order"])',
'htmlOptions' => array(
'style' => 'width:50px;'
)
),
array(
'name' => 'Status',
'value' => 'CHtml::encode($data["status"])',
),
array(
'name' => 'Timestamp',
'value' => 'CHtml::encode($data["change_ts"])',
),
),
));
?>
So I want user to select option from dropdown, select date and make SQL query from this values. Then I want to pass results to CGridView.
Please Help... I'm stuck
This is what gii generates:
Yii::app()->clientScript->registerScript('search', "
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('category-grid', {
data: $(this).serialize()
});
return false;
});
");
Use the $.fn.yiiGridView.update to update your grid.
Related
Following is my code.
<script type="text/javascript">
//jQuery(document).ready(function($) {
//jQuery('select[name="Vendor"]').on('change', function(){
jQuery('select[name="Vendor"]').change(function(){
var selectedValue = $(this).val();
alert("Selected Text: " + selectedValue);
if(this.value ==2){
jQuery('.grid_data').show();
}else{
jQuery('.grid_data_rel').show();
}
});
//});
</script>
When i change select value event only occur for one time not alert showing on second time.
Html is coming from yii grid view like
'filter'=>array('1'=>"Recomonded",'2'=>"Related"), this is html in code and i used in yii frame work.
so here i can not see my static html code it's coming from gridview in yii.
<?php
$sql = "SELECT product_id,product_name FROM `user_master` as u
INNER JOIN product_detail as p
ON p.vendor_id = u.u_id WHERE p.vendor_id =2";
$result = Yii::app()->db->createCommand($sql)->queryAll();
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-master-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'u_id',
// 'product_id',
// 'ut_id',
// 'country_id',
'fullname',
// 'ur.role_name',
array(
'header' => 'Role Name',
'name' => 'ur_id',
'value' => '$data->ur->role_name',
),
array(
'header' => 'Product Name',
'name' => 'product_id',
'value' => '$data->product_detail->product_name',
),
array(
'header' => 'Qty',
'name' => 'product_id',
'value' => '$data->product_detail->quantity',
),
array(
'header' => 'product_id',
'name' => 'product_id',
'value' => '$data->product_detail->product_id',
),
// 'representative_name',
'email',
// 'password',
'mobile',
array(
'header' => 'Image',
'name' => 'u_id',
'id'=>'u_id',
'type' => 'raw',
'filter'=>array('1'=>"Recomonded",'2'=>"Related"),
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
It's likely that the gridview is loading new html using ajax.
If that's the case, then your event listeners won't be attached to the new replacement select elements.
Why not use the commented out .on() method?
Move back to delegated events:
<script type="text/javascript">
jQuery(document).on('change', 'select[name="Vendor"]', function(){
if(this.value ==2){
jQuery('.grid_data').show();
}else{
jQuery('.grid_data_rel').show();
}
});
HI i Want to create Alpha Pager search , search is working fine but when i click search it disturb UI like load header and menu second time and site start showing menu again
Here is admin.php view page:
<?php
/* #var $this AreaController */
/* #var $model Area */
$this->breadcrumbs = array(
'Areas' => array('index'),
'Manage',
);
?>
<h1>Manage Areas</h1>
<div>
<?php
echo CHtml::ajaxLink('F', Yii::app()->createUrl('area/admin'), array('data' => array('q' => 'F'), 'update' => '#area-grid'), array());
echo CHtml::ajaxLink('E', Yii::app()->createUrl('area/admin'), array('data' => array('q' => 'E'), 'update' => '#area-grid'), array());
//echo CHtml::link('S', array('area/admin', 'q' => 'S'), array('target' => '_blank'));
?>
</div>
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'area-grid',
'itemsCssClass' => 'table-bordered items',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
array(
'class' => 'editable.EditableColumn',
'name' => 'Area',
'headerHtmlOptions' => array('style' => 'width: 110px'),
'editable' => array(//esditable section
'url' => $this->createUrl('area/updateEditable', array('model' => 'Area', 'field' => 'status')),
'placement' => 'right',
)
),
array(
'class' => 'editable.EditableColumn',
'name' => 'status',
'headerHtmlOptions' => array('style' => 'width: 100px'),
'editable' => array(
'type' => 'select',
//'url' => Area::getStatusList(),
'url' => $this->createUrl('area/updateEditable', array('model' => 'Area', 'field' => 'status')),
'source' => $this->createUrl('area/getStatuses'),
'options' => array(//custom display
'display' => 'js: function(value, sourceData) {
var selected = $.grep(sourceData, function(o){ return value == o.value; }),
colors = {"Active": "green", "InActive": "red"};
$(this).text(selected[0].text).css("color", colors[value]);
}'
),
//onsave event handler
'onSave' => 'js: function(e, params) {
console && console.log("saved value: "+params.newValue);
}',
'htmlOptions' => array(
'data-username' => '$data->status'
)
)
),
),
));
?>
Controller admin action code:
public function actionAdmin() {
$model = new Area('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Area']))
$model->attributes = $_GET['Area'];
$this->render('admin', array(
'model' => $model,
));
}
Model search function code:
public function search() {
// #todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria;
$criteria = new CDbCriteria;
if (isset($_GET['q'])) {
$criteria->condition = 'Area like "' . $_GET["q"] . '%" ';
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
$criteria->compare('id', $this->id);
$criteria->compare('Area', $this->Area, true);
$criteria->compare('status', $this->status, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
I am displaying form elements in my CGridView and would like datepicker, but it complains
CDataColumn and its behaviors do not have a method or closure named "widget".
I have modified DATEIN using the method described in Use a widget in a statically-called method However i think it works partially as when i do a sort or the datepicker does not work. its working only on initial load.
<script>
$(document).ready(function() {
/*
$("input[name*='DATEIN'] ").each(function(){
jQuery(this).datepicker({'dateFormat':'<?=Yii::app()->params["localdate"]; ?>'});
});
*/
$("input[name*='datedone'] ").each(function(){
jQuery(this).datepicker({'dateFormat':'<?=Yii::app()->params["localdate"]; ?>'});
});
});
</script>
<?php
$job = new Jobs();
$buttonPlus = CHtml::ajaxLink('Add New Line', $this->createUrl('addNewLine',array("id"=>$model->id)), array(
'type' => 'POST',
'data' => array('id' => $model->id),
'success' => 'function(html){ $.fn.yiiGridView.update("jobs-grid"); $.fn.yiiGridView.update("detailsseismic-grid"); $.fn.yiiGridView.update("details3d-grid"); }'
));
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'jobs-grid',
'dataProvider'=>$job->searchbyproject($model->PROJID),
'afterAjaxUpdate'=>'function(id,options){
$("#jobs-grid").children("table").children("thead").children("tr").children("th").children("a").each(function(){
$(this).click(function(){
var x = getQueryParams(this.href);
if($("#detailsgeoscan-grid").length)
$.fn.yiiGridView.update("detailsgeoscan-grid",{data:"sort="+x.sort});
else if($("#detailsseismic-grid").length)
$.fn.yiiGridView.update("detailsseismic-grid",{data:"sort="+x.sort});
else if($("#details3d-grid").length)
$.fn.yiiGridView.update("details3d-grid",{data:"sort="+x.sort});
});
});
$("#jobs-grid").children("div").children("ul").children("li").children("a").each(function(){
$(this).click(function(){
var x = getQueryParams(this.href);
if($("#detailsgeoscan-grid").length)
$.fn.yiiGridView.update("detailsgeoscan-grid",{data:"Detailsgeoscan_page="+x.Jobs_page});
else if($("#detailsseismic-grid").length)
$.fn.yiiGridView.update("detailsseismic-grid",{data:"Detailsseismic_page="+x.Jobs_page});
else if($("#details3d-grid").length)
$.fn.yiiGridView.update("details3d-grid",{data:"Details3d_page="+x.Jobs_page});
});
});
/*
$("input[name*=\'DATEIN\'] ").each(function(){
jQuery(this).datepicker({"dateFormat":"'. Yii::app()->params["localdate"]. '"});
});
*/
$("input[name*=\'datedone\'] ").each(function(){
jQuery(this).datepicker({"dateFormat":"'. Yii::app()->params["localdate"].'"});
});
}',
'summaryText' => '',
'columns'=>array(
array(
'name'=>'JOBNO',
'value'=>'CHtml::activeHiddenField($data, "[$row]JOBNO")' ,
'type'=>'raw',
'headerHtmlOptions' => array('style' => 'display:none;'),
'htmlOptions' => array('style' => 'display:none'),
'footer' => $buttonPlus,
'footerHtmlOptions'=> array('colspan' => '7'),
),
array(
'name'=>'NAME',
'value'=>'CHtml::activeTextField($data, "[$row]NAME", array("size"=>25))' ,
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
array(
'name'=>'SEQ',
'value'=>'CHtml::activeTextField($data, "[$row]SEQ", array("size"=>15))' ,
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
array(
'name'=>'DATEIN',
//'value'=>'CHtml::activeTextField($data, "[$row]DATEIN", array("size"=>10))' ,
'value' => function ($data, $row, $column) {
$controller = $column->grid->owner;
echo $controller->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$data,
'attribute'=>'DATEIN',
// additional javascript options for the date picker plugin
'htmlOptions'=>array(
'class'=>'datefield',
'id' => 'Jobs_'.$row.'_DATEIN',
),
'options' => array(
'dateFormat' => Yii::app()->params["localdate"],
)
),true);
},
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
array(
'header'=>"Process Complete <div id='checkboxgroup'> $processcompleteheader </div>",
'value'=>'$data->getcheckboxProcesses($row)',
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
array(
'name'=>'DATEDONE',
'value'=>'CHtml::activeTextField((count($data->jobsprocesscomplete)>0) ? $data->jobsprocesscomplete(array("order"=>"datedone desc")) : new Jobsprocesscomplete , "[$row]datedone", array("size"=>10))' ,
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
'sortable' => false,
),
array(
'name'=>'COMMENTS',
'value'=>'CHtml::activeTextField($data, "[$row]COMMENTS", array("style"=>"width:150px"))' ,
'type'=>'raw',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
array(
'header'=>'<a id="deletealljobs" title="Delete All Lines" onclick="deleteAllJob(\'1409099\')" href="#">X</a>',
'class'=>'CButtonColumn',
'template'=>'{delete}',
'footerHtmlOptions'=> array('style' => 'display:none'),
),
),
));
?>
I render it on from another view
$processcompleteheader = null;
foreach ($processstages as $k => $v) {
$processcompleteheader .= CHtml::Checkbox($k."_all",'',array("value"=>$k,"title"=>$v));
}
$lineListContent = "<div id='form_line_list'>
<div style='display: block;
left: 565px;
position: absolute;
top: 7px;'> " .CHtml::hiddenField("PROJID",$model->PROJID) . CHtml::hiddenField("id",$model->id) . CHtml::activeFileField(new Fileupload,'jobs', array('onChange'=>'showLoadDialog();submit(this)'))."<a id=clearfile href=# onclick='clearfile()' />X</a></div>";
$lineListContent .= $this->renderPartial("/jobs/_formJobsGridview",array("model"=>$model,"processcompleteheader"=>$processcompleteheader),true);
$lineListContent .= "</div>";
I think this question over here can help you out:
Use a widget in a statically-called method
Basically this widget can be called by the controller, but in your code you are trying to call it by the gridview.
I am trying to integrate jqgrid and jqform but the data is not being populated into my jqform. I tested to make sure the jqgrid is passing over search key value for the form, and that works. But for some reason, my reform will not query correctly and populate form objects.
<?php
if(!isset($_SESSION))
session_start();
// Include class
include_once 'jqformconfig.php';
if(!class_exists('jqGridUtils'))
{
include_once $CODE_PATH.'jqUtils.php';
}
include_once $CODE_PATH.'jqForm.php';
$today = getdate(time());
$displayDate = $today['mon']."/".$today['mday']."/".$today['year'].' '.$today['hours'].':'.$today['minutes'].':'.$today['seconds'];
$machrecs = null;
// Create instance
$newForm = new jqForm('MWOForm',array('action' => 'forms/mwoForm.php', 'method' => 'post', 'id' => 'MWOForm'));
// Demo Mode creating connection
if(!class_exists('jqGridDB'))
{
include_once $CODE_PATH.'/jqGridPdo.php';
}
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
$conn->query("SET NAMES utf8");
$newForm->setConnection( $conn );
// Set url
$newForm->setUrl($SERVER_HOST.$SELF_PATH.'forms/mwoForm.php');
// Set parameters
$mwo_id = jqGridUtils::GetParam('mwo_id',0901270825);
$mwo_id = is_numeric($mwo_id) ? (int)$mwo_id : 0;
$jqformparams = array($mwo_id);
// Set SQL Command, table, keys
$newForm->SelectCommand = 'SELECT mwo_id, asset_id, short_desc as machDesc
FROM mfg_eng_mwo.mwo
WHERE mwo_id =?';
$newForm->table = 'mfg_eng_mwo.mwo';
$newForm->setPrimaryKeys('mwo_id');
$newForm->serialKey = true;
// Set Form layout
$newForm->setColumnLayout('twocolumn');
$newForm->setTableStyles('width:500px;','','');
$statusSQL = 'SELECT distinct type FROM mfg_eng_mwo.wo_status';
$prioritySQL = 'SELECT distinct type FROM mfg_eng_mwo.wo_priority';
$deptSQL = 'SELECT dept_id FROM mfg_eng_mwo.department';
$deptData = '-1:Select a Department';
$machData = "";
$assetData = "";
$postData = "";
if(isset($row))
{
$deptData = "$row[dept]:$row[dept]";
$machData = "$row[asset_no]:$row[machDesc]";
$assetData =$row['asset_no'];
$postData = $row['post'];
}
$parts = '-:Order Parts?;1:YES;0:NO';
$tools = '-:Order Tools?;1:YES;0:NO';
// Add elements
$newForm->addElement('woStatus', 'select', array('label' => '<b>Status</b>', 'datasql' => $statusSQL, 'id' => 'woStatus', 'required'=>true));
$newForm->addElement('WOPriority', 'select', array('label' => '<b>Priority</b>', 'datasql' => $prioritySQL, 'id' => 'woPriority'));
$newForm->addElement('dept', 'select', array('label' => '<b>Deptartment</b>', 'datalist' => $deptData, 'datasql' => $deptSQL, 'id' => 'dept', 'required'=>true));
$newForm->addElement('machDesc', 'select', array('label' => '<b>Machine Desc</b>', 'datalist' => $machData, 'id' => 'machDesc','required'=>true));
$newForm->addElement('asset_id', 'text', array('label' => '<b>Asset ID#</b>', 'value' => $assetData, 'size' => '20', 'id' => 'MWOForm_asset_id', 'readonly'=>true, 'required'=>true));
$newForm->addElement('post', 'text', array('label' => '<b>Post</b>', 'value' => $postData, 'maxlength' => '40', 'id' => 'post', 'readonly'=>true, 'required'=>true));
$newForm->addElement('requester', 'text', array('label' => '<b>Requester</b>', 'value' => $_SESSION['user'], 'maxlength' => '60', 'id' => 'requester', 'readonly'=>true, 'required'=>true));
$newForm->addElement('enterTime', 'text', array('label' => '<b>Created</b>', 'value' => $displayDate, 'maxlength' => '15', 'size' => '20', 'id' => 'enterTime', 'readonly'=>true,'required'=>true));
//$newForm->addElement('short_desc', 'text', array('label' => '<b>Short Description</b>', 'maxlength' => '15', 'size' => '20', 'id' => 'short_desc', 'required'=>true));
//$newForm->addElement('parts', 'select', array('label' => '<b>Parts Needed</b>', 'datalist' => $parts, 'id' => 'parts', 'required' => 'true', 'hidden' => 'true'));
//$newForm->addElement('tools', 'select', array('label' => '<b>Tools</b>', 'datalist' => $tools, 'id' => 'tools', 'hidden' => 'true'));
$newForm->addElement('problem', 'textarea', array('label' => '<b>Problem</b>', 'rows' => "3", 'cols' => "50", 'id' => 'problem', 'required'=>true));
$newForm->addElement('solution', 'textarea', array('label' => '<b>Solution</b>', 'rows' => "3", 'cols' => "50", 'id' => 'solution'));
$elem_8[]=$newForm->createElement('newSubmit','submit', array('value' => 'Submit'));
$newForm->addGroup("newGroup",$elem_8, array('style' => 'text-align:right;', 'id' => 'newForm_newGroup'));
// Add events
$onchangeDept = <<< CHANGEDEPT
function(event)
{
$("#machDesc").show();
var deptval = $("#dept").val();
jQuery.ajax(
{
url: 'machine.php',
dataType: 'json',
data: {q:deptval},
success : function(response)
{
$('#machDesc').find('option').remove();
$('#machDesc').append('<option value=-1>Select Equipment</option>');
jQuery.each(response, function(i,mach)
{
$('#machDesc').append('<option value='+mach.asset_no+'>'+mach.asset_no+'::'+mach.short_desc+'</option>');
});
$('#asset_no').val('');
$('#post').val('');
}
});
}
CHANGEDEPT;
$newForm->addEvent('dept','change',$onchangeDept);
$onchangeMach = <<< CHANGEMACH
function(event)
{
var assetval = $("#machDesc").val();
jQuery.ajax(
{
url: 'post.php',
dataType: 'json',
data: {q:assetval},
success : function(response)
{
jQuery.each(response, function(i,mach)
{
$('#MWOForm_asset_id').val(mach.asset_no);
$('#post').val(mach.post);
});
}
});
}
CHANGEMACH;
$newForm->addEvent('machDesc','change',$onchangeMach);
$beforeSubmit = <<< BS
function(arr, form, options)
{
var toolval = $("#tool").val();
var partval = $("#part").val();
if(toolval == 0 || toolval == 1)
{
alert("Please select 'YES' or 'NO' for tools.");
return false;
}
if(partval != 1 || partval != 0)
{
alert("Please select YES or NO for tools.");
return false;
}
}
BS;
// Add events
$onclicknewButton = <<< CLICKNEWBUTTON
function(event)
{
if($("#ajax-dialog") ) {
$("#ajax-dialog").remove();
}
}
CLICKNEWBUTTON;
$newForm->addEvent('close_modal','click',$onclicknewButton);
// Add ajax submit events
$success = <<< SU
function( response, status, xhr) {
if(response=='success')
{
$("#grid").trigger("reloadGrid", [{current:true}]);
}
}
SU;
// Add ajax submit events
$newForm->setAjaxOptions( array('dataType'=>null,
'resetForm' =>false,
'clearForm' =>false,
'success' =>'js:'.$success,
'beforeSubmit' =>'js:'.$beforeSubmit,
'iframe' => false,
'forceSync' =>false) );
// Render the form
echo $newForm->renderForm($jqformparams);
?>
</body>
How to Pop Up A New Windwon In Gridview?
When the use click the refund button of gridview, I would like to display the popup box with the data. How can I do?
This is the my gridview
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'advance-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array('name' => 'acc_category_id',
'value'=>'(isset($data->acccategories->name)) ? CHtml::encode($data->acccategories->status) :"Not Set"',
'filter'=>CHtml::listData($acccate, 'id', 'name'),
),
array('name' => 'accmain_id',
'value'=>'(isset($data->accmains->name)) ? CHtml::encode($data->accmains->name) :"Not Set"',
'filter'=>CHtml::listData($accmain, 'id', 'name'),
),
array('name' => 'job_id',
'value'=>'(isset($data->jobs->name)) ? CHtml::encode($data->jobs->name) :"Not Set"',
//'filter'=>CHtml::listData($job, 'id', 'name'),
),
'currency',
'amount',
array('name' => 'created_date',
'value'=>'Yii::app()->dateFormatter->format("d MMM y",strtotime($data->created_date))',
// 'filter'=>CHtml::listData($job, 'id', 'name'),
),
array(
'class'=>'CButtonColumn',
'template'=>'{update} {delete} {refund}',
'buttons'=>array
(
'update' => array
(
'imageUrl'=>Yii::app()->request->baseUrl.'/protected/assets/images/gridview/edit.gif',
'options'=>array('style'=>'width:10px; border:none;'),
'url'=>'Yii::app()->createUrl("advance/update", array("id"=>$data->id))',
),
'delete' => array
(
'imageUrl'=>Yii::app()->request->baseUrl.'/protected/assets/images/gridview/delete.gif',
'options'=>array('style'=>'width:10px; border:none;'),
'url'=>'Yii::app()->createUrl("advance/delete", array("id"=>$data->id))',
),
'refund' => array
(
'type'=>'raw',
'imageUrl'=>Yii::app()->request->baseUrl.'/protected/assets/images/gridview/icon_refund_loans2.gif',
'options'=>array('style'=>'width:10px; border:none;'),
'url'=>'Yii::app()->createUrl("advance/view", array("id"=>$data->id))',
),
),
),
),
'htmlOptions' => array(
//'class' => 'table table-bordered table-striped table_vam grid_widget',
),
)); ?>
<div id="loadingdiv" style="float:right; margin-right:160px;"> </div>
<div id="jobslist"></div>
=====================================
update
when I update the grid by following and check by firebug, it is displaying the data at firebug. but not display popup.
array(
'header'=>'Refund',
'type'=>'raw',
'value'=>'CHtml::ajaxLink($data->id, array("advance/jobslist", "id"=>$data->id), array("onclick"=>\'$("#jobslist").dialog("open"); return false;\'));',
),
This is controller
public function actionJobslist()
{
$model=new Job('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Customer']))
$model->attributes=$_GET['Customer'];
if(isset($_GET['AccRecei']))
$accrecei->attributes=$_GET['AccRecei'];
$this->renderPartial('jobs_listing',array('model'=>$model),false,true);
}
this is view/jobs_listing.php
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'jobslist',
'options'=>array(
'title'=>Yii::t('job','Jobs List'),
'autoOpen'=>true,
'modal'=>'true',
'width'=>'750',
'height'=>'500',
),
));
echo $this->renderPartial('_jobs_listing', array('model'=>$model)); ?>
<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>
how should I do?
array(
'header'=>'Refund',
'type'=>'raw',
'value'=>'CHtml::link($data->id, array("id"=>$data->id, 'class'=>'view-popup'));',
),
and insert javascript:
$('.view-popup').live('click', function() {
var id = $(this).attr('id');
window.open("<?php echo 'http://'.$_SERVER['HTTP_HOST'].'/your_path/id/'; ?>" + id,'popUpWindow','height=800,width=1000,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes');
return false;
});
Inner of the grid
array(
'header'=>'Refund',
'type'=>'raw',
'value'=>'CHtml::ajaxLink($data->id, array("advance/jobslist", "id"=>$data->id), array(
"onclick"=>"$(\"#jobslist\").dialog(\"open\"); return false;","update"=>"#jobslist",
"beforeSend" => "function() {
$(\"#loadingdiv\").addClass(\"ajaxloading\");
}",
"complete" => "function() {
$(\"#loadingdiv\").removeClass(\"ajaxloading\");
}",
),array("id"=>"showcustomerlist2"));',
),
Out of the grid
<div id="loadingdiv" style="float:right; margin-right:160px;"> </div>
<div id="jobslist2"></div>