Yii Framework Forum: filterHtmlOptions - style user input in filter box - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

filterHtmlOptions - style user input in filter box

#1 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 379
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 30 July 2015 - 06:00 AM

Tip:

If you want to style the content that the user enters in the CGridView's filterbox (for example "text-align : right") then
'filterHtmlOptions'=>array('style'=>'text-align: right'),

is NOT going to work, because it will only style the outer table cell (td), and not the inner filter-container (div) or input element:

<td style="text-align: right">
    <div class="filter-container">
        <input>
    </div>
</td>


What you can do is add a class to the outer table cell:
'filterHtmlOptions'=>array('class'=>'filterBoxRight'),

which will result in this:
<td class="filterBoxRight">
    <div class="filter-container">
        <input>
    </div>
</td>

Then use the following code to style the <input>:

$(document).on('ready', function(){
    $('.filterBoxRight').find('.filter-container').find(':input').css({
        'text-align': 'right'
    });
});

0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,526
  • Joined: 12-October 09
  • Location:Croatia

Posted 30 July 2015 - 06:11 AM

Nice tip

/* Moved to proper forum section, from General Discussion for Yii 1.1.x to Tips, Snippets and Tutorials */
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users