PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 9, 2022

[FIXED] Decimal Format in Yii TBGridview

 January 09, 2022     cgridview, php, yii     No comments   

Issue

I have code like this :

<?php 
$this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'appliances-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
        array(
            'name'=>'price',
            'type'=>'number',
            'htmlOptions'=>array('style' => 'text-align: right;'),
        ),
        array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'template'=>'{update}{delete}'
        ),
    ),
)); 
?>

the result is integer number only and search filter is work, how to change it into decimal format but search filter still working ?
I tried to change it into :

array(
    'name'=>'price',
    'type'=>'number',
    'htmlOptions'=>array('style' => 'text-align: right;'),
    'value'=>function($data)
             {
                return number_format($data->price,2,',','.');
             },
),

But it makes search filter not working properly.


Solution

I found the answers here :

  1. Yii Number Formatting
  2. How to format numeric string using C.Gridview - Yii

And also I found this link Yii , show different date format in cgridview



Answered By - Cuheguevara
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing