Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'tbgridview'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. The problem I have is that I am returning a subset of data from the User table to a view. Using TbGridView I should be able to type in a search term and this data should be filtered by my search term however the data is not filtered. The same data is simply retuned. The filtering is not working. I have an action in my User controller to show a list of users that have previously logged in. The action is public function actionLoginhistory() { $model=new User('searchlogin'); $model->unsetAttributes(); // clear any default values if(isset($_GET['User'])) { $model->attributes=$_GET['User']; } $this->render('loginlist', array( 'model'=>$model, )); } This returns the correct data set to my view. The problem is that when I try to filter the data by typing in a search term in the Trading Name column or Email column the same data set is returned. The view code is: $this->widget('bootstrap.widgets.TbGridView', array( 'type' => 'striped bordered condensed', 'dataProvider' => $model->searchlogin(), 'filter'=>$model, 'ajaxUpdate'=>false, 'enablePagination'=>true, 'summaryText'=>'Displaying {start}-{end} of {count} results.', 'template' => "{summary}{items}{pager}", 'htmlOptions'=>array('style' => 'width:500px;margin-left: 130px;',), 'columns' => array( array('name' => 'real_name', 'header'=> 'Trading Name','htmlOptions'=>array('width'=>'50%'), 'type'=>'raw', 'value' =>'CHtml::link($data->real_name, array("contractors/viewalldocuments","id"=>$data->username))', ), array('name' => 'email', 'header' => 'Email','htmlOptions'=>array('width'=>'30%')), array('name' => 'last_login', 'header' => 'Last Login', 'filter'=>false, 'htmlOptions'=>array('width'=>'20%'), 'value' => 'date("d-m-Y", strtotime($data->last_login))'), )) The data set returned is from the User model - the code for this is: public function searchlogin() { $criteria=new CDbCriteria; $criteria->compare('real_name', $this->real_name); $criteria->condition = 'last_login IS NOT NULL AND user_type_id=4'; return new CActiveDataProvider('User', array( 'pagination' => array( 'pageSize' => 80, ), 'criteria'=>$criteria, )); } If I change my view code to use the standard search function then every user in the user table is returned and the data will filter down by search term. So if I change one line in the view to 'dataProvider' => $model->search(), Then every user is returned but the data will filter by search term. The standard search function in the model this refers to in the User Model is public function search() { $criteria=new CDbCriteria; $criteria->compare('real_name',$this->real_name,true); $criteria->compare('username',$this->username,true); $criteria->compare('email',$this->email,true); $criteria->compare('last_login',$this->last_login,true); return new CActiveDataProvider($this, array( 'pagination' => array( 'pageSize' => 80, ), 'criteria'=>$criteria, )); } This should be really straight forward and simple. You should be able to have multiple search functions in a Model - I have been looking at this for days and I just cannot resolve the problem. I would appreciate any help. When I type in the search term the code generates what I would expect the url to be
×
×
  • Create New...