Thursday, December 22, 2011

Fancy box in CGridView in Yii Framework

$this->widget('zii.widgets.grid.CGridView', array(
 'id'=>'travel-details-grid',
        //here we need to mention the fancy box function after ajax  
 'afterAjaxUpdate'=>"function(id,data){ $('a[rel=viewtravel]').fancybox({
    'transitionIn'  : 'none',
    'transitionOut'  : 'none',
    'titlePosition'  : 'outside',
    'titleFormat'  : function(title, currentArray, currentIndex, currentOpts) {
     return 'Transit Details ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '   ' + title : '') + '';
    }
 }); }",
 'dataProvider'=>$model->search(),
 //'filter'=>$model,
 'columns'=>array(
  'td_first_name',
  'td_travel_depart_date',
  'td_travel_arrive_date',
  array(
   'class'=>'CButtonColumn',
   'header'=>'Actions',
   'template'=>'{view}', 
   'buttons'=>array
   (
    'view' => array
    (
     'label'=>'View',
     'options'=>array('rel'=>'viewtravel','class'=>'fancy'),
     'url'=>'Yii::app()->createUrl("travelDetails/adminview",array("id"=>$data->id))',
    ),
   ),          
  ),
 ),
)); 

-->

Customize CGridView in Yii Framework

To add

tag far data

$this->widget('zii.widgets.grid.CGridView', array(
 'id'=>'country-expert-grid',
 'dataProvider'=>$model->search(),
 'filter'=>$model,
 'columns'=>array(
  'ce_location_country',
  'ce_location_city',
                //add 

tag in column data 'ce_title'=>array( 'type'=>'html', 'name'=>'ce_title', 'value'=>'"

".$data->ce_title."

"', ), //'ce_title', array( 'class'=>'CButtonColumn', 'header'=>'Actions', ), ), ));

Friday, December 9, 2011

Multiple ajax call

While calling multiple ajax call in a page sometimes ajax call do not take place for that we need to place the  below code before ajax call
$.ajaxSetup ({ 

        cache: false 

    });
Example:
$.ajaxSetup ({ 

        cache: false 

    });

    $('#city_id').change(function(){

        $('#weatherreport').html('".$Loadingimage."').load('".$vUrl."?id='+this.value+'&ajax=1');

        return false;

    });

Thursday, December 8, 2011

Sort records in CGridView data provider

$criteria = new CDbCriteria();
Edit the above code to below code in your model
$criteria = new CDbCriteria(array(

                            'order' => 'id DESC'

                        ));
It will works fine.

Tuesday, October 4, 2011

Difference between echo and print

The main difference between echo() and print() is that echo is just an statement not a function and doesn't return's value or it just prints a value whereas print() is an function which  prints a value and also it returns value.

Yii

Yii is a high-performance PHP framework best for developing Web applications. Yii comes with features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc. It can reduce your development time significantly.

Select Top Second Salary

 1. To find exact second salary
         select max(salary) from jos_emp where salary < (select max(salary) from jos_emp)
2. To find all second salary
         select salary from jos_emp where salary=(select max(salary) from jos_emp where salary < (select max(salary) from jos_emp)).