YiiBooster icon indicating copy to clipboard operation
YiiBooster copied to clipboard

TbExtendedGridView not filtering when fixedHeader set to true

Open onesource4u opened this issue 12 years ago • 8 comments

When fixedHeader is set to true for TbExtendedGridView the filter will not work on any columns.

Found this issue in my personal project. Same issue is also on the current Yii Booster TbExtendedGridView page: http://yiibooster.clevertech.biz/extendedGridView/index.html

onesource4u avatar Dec 02 '13 19:12 onesource4u

It doesnt work for me even with fixed header option commented out or set to false. Here is my code, pls correct me if i am doing a thing wrongly. Thanks

$this->widget('bootstrap.widgets.TbExtendedGridView', array(
        'cssFile' => $this->assetsPath . '/css/bootstrap.css',
        //'fixedHeader' => false,
        //'headerOffset' => 40,   // 40px is the height of the main navigation at bootstrap
        'filter'=>$model,
        'type' => 'striped bordered hover myGridView',
        'dataProvider' => $model->search(),
        'responsiveTable' => true,
        'template' => "{items}",
        'columns' => array(
                array(
                    'class'=>'CCheckBoxColumn',   
                    'selectableRows'  => 2,
                    'value' => '$data->id',
                    'checkBoxHtmlOptions' => array('name'=>'Plan[cid][]'),
                ),
        'id',
        'plan_name',
        'amount',
        'status',
                array(
                        'htmlOptions' => array('nowrap'=>'nowrap'),
                        'class'=>'bootstrap.widgets.TbButtonColumn',
                ),
    ),
    )
);

swedge218 avatar Feb 07 '14 15:02 swedge218

hi nothing wrong with your code, are you sure you are catching the params sent and filtering the result based on it?

amrbedair avatar Apr 17 '14 17:04 amrbedair

current version 4.0.1 have this problem.fixed header false work and true not work.

salimionnet avatar Aug 20 '14 06:08 salimionnet

It can be fixed by these steps:

  1. find file /protected/extensions/booster/assets/js/jquery.stickytableheaders.js
  2. in this file find line, which contains base.$clonedHeader = base.$originalHeader.clone(); (my line 51)
  3. after this line insert following code:
   var filters = base.$clonedHeader.find(".filters input");
   if(filters.length > 0)
      filters.removeAttr("name");

You are done. It causes, that cloned header will not have input attribute "name". So when JS serialize() is called, inputs without attribute "name" are ignored.

DAMI-Michal-Bajer avatar Oct 23 '14 20:10 DAMI-Michal-Bajer

Can this fix be added to next release? Changing YiiBooster code is not the best option while using Composer to get YiiBooster and other dependencies on multiple systems including production. Since jquery.stickytableheaders.js is registered as an individual js asset (instead of a package), it cannot be overridden either.

thanks

bravo2 avatar Nov 01 '14 06:11 bravo2

Since jquery.stickytableheaders.js is maintained in another party, so I guess it will be better to add code in TbExtendedGridView.php

idea: jquery select the clone table and remove the name attribute (see DAMI-Mike solution)

line: 692

$fixedHeaderJs = "$('#{$this->id} table.items').stickyTableHeaders({fixedOffset:{$this->headerOffset}});";`

after this line add:

            $fixedHeaderJs .= "var filters = $('#{$this->id} table.items .tableFloatingHeader').find('.filters input');
               if(filters.length > 0)
                  filters.removeAttr('name');";
            $this->componentsAfterAjaxUpdate[] = $fixedHeaderJs;

thanks to DAMI-Mike

can someone put this in the next release?

d3artagnan avatar Nov 13 '14 17:11 d3artagnan

@d3artagnan I ended up doing the same from my page level javascript.

Ideally, jquery.stickytableheaders.js should be configured as a package in YiiBooster, similar to many other libraries included. This will allow the YiiBooster users to substitute the plugin file from application level.

bravo2 avatar Nov 13 '14 17:11 bravo2

The Solution postet from @DAMI-Mike works for most kind of Input, but if you have a Dropdown it will not work. Use this for Dropdown and Textfields:

var filters = base.$clonedHeader.find(".filters input, .filters select");
if(filters.length > 0)
 filters.removeAttr("name");

lugaru90 avatar Dec 03 '14 13:12 lugaru90