Yii, filtering and ordering column in grid view that has data from custom model function -


This question is followed:

I found that cell It's working, but now I do not know how to sort it and filterable (the filter field is hidden).

See:

  $ this-> Widgets ('Bootstrap .widgets.TbExtendedGridView', array ('id' => User-Grid, 'Detector' => $ model-> Search (), 'Filter' = & gt; $ Model, 'column' = & gt; array ('user_name', 'favorite_color', array ('value' = & gt; '$ data-> getAllDates ()',),),))))));   

A user may have multiple dates which can be a single date or date range, so I have found the AllDates function that receives all of them and all of them in the string So that the user can represent within a single cell.

Model:

  Public function relation () {return array ('listofdates' => array (auto :: HAS_MANY, 'dates', 'user_id') ,); } Public function getAllDates () {$ data = ''; Foreign currency ($ this-> listofdates $ date) {$ data. = $ Date-> Start_date '-'. $ Date- & gt; End_date; } Return $ data; }   

I do not know how to enable filtering and search for date column. I do not have any title or filter field for that column 'name' = & gt; I can enable filter fields by adding. Whatever ', but there is definitely no column in the database for that database, I get the MySQL error. I'm guessing that I need to create another custom function to filter, but I do not know That's where to start from.

You can create additional fields for sorting and sorting $ dates. Filter and filter like this: / p>

In model:

  public $ dates filter; Public Function Rules () (array ('date filter', 'safe', 'on' => = 'search')); } Public function search () {$ criteria = new CDBCRITERIA; ... // If filtering ($ this-> Dates filter! == empty) $ criteria- & gt; Engagement ('Your Search Conditioning'); ... // sorting $ sort = new cssort; $ Sort- & gt; Attribute = array (... 'datesFilter' => = & gt; array ('ASC' => 'Your Source ASC', 'Dell' => 'Sort Your DESC')); }   

In this view:

  $ this-> Widget ('bootstrap.widgets.TbExtendedGridView', array ('id' = & gt; 'user-grid', 'data provider' => = model-> search (), 'filter' = & gt; $ Model, 'column' = & gt; array ('user_name', 'favorite_color', array ('value' =) & gt; '$ data- & gt; getAllDates ()', 'name' = & gt; dates' datefilter ',),),)));    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -