Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'searchmodel'.

  • 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. I want to be able to click on a link from the registration gridview, and filter the results of the players gridview so only the players I selected show up. Right now, it's not filtering. I get all the players. I have the following tables: - registrations - players From the registrations/index gridview I have a link so I can edit players: <?= DynaGrid::widget([ 'columns' => [ ['attribute'=>'playersEditLink', 'format'=>'raw'], [ 'label'=>'Player(s)', 'format' => 'raw', 'value' => function ($dataProvider) { $str = ''; foreach($dataProvider->players as $name) { $str .= ' '; $str .= $name->first.' '; $str .= $name->last.'<br />'; } return nl2br($str); }, 'filter' => function ($dataProvider) { $str = ''; foreach($dataProvider->players as $name) { $str .= ' '; $str .= $name->first.' '; $str .= $name->last.'<br />'; } return nl2br($str); }, ], //'transactionID', // divisionLevel dropdown editable column [ 'class' => 'kartik\grid\EditableColumn', 'header' => 'Division Level', 'attribute' => 'divisionLevelID', 'value' => 'divisionLevelName', 'pageSummary' => true, 'editableOptions'=> function ($model, $key, $index, $widget) { $divisionlevels = ArrayHelper::map(DivisionLevelAssignment::find()->where(['active'=>1])->orderBy('divisionlevelID')->asArray()->all(),'divisionlevelID','exportName'); return [ 'header' => 'Division Level', 'size' => 'sm', 'inputType' => 'dropDownList', 'displayValueConfig' => $divisionlevels, 'data' => $divisionlevels ]; } ], // field dropdown editable column [ 'class' => 'kartik\grid\EditableColumn', 'attribute' => 'field', 'value' => 'fieldName', 'pageSummary' => true, 'editableOptions'=> function ($model, $key, $index, $widget) { $fields = ArrayHelper::map(Fields::find()->all(), 'id','name'); return [ 'header' => 'Field', 'size' => 'sm', 'inputType' => 'dropDownList', 'displayValueConfig' => $fields, 'data' => $fields ]; } ], // editable net column [ 'class'=>'kartik\grid\EditableColumn', 'attribute'=>'net', 'editableOptions'=>[ 'header'=>'Net', 'inputType'=>'textInput', 'options'=>['pluginOptions'=>['min'=>1, 'max'=>60]] ], 'hAlign'=>'right', 'vAlign'=>'middle', 'width'=>'50px' ], // editable team column [ 'class'=>'kartik\grid\EditableColumn', 'attribute'=>'team', 'editableOptions'=>[ 'header'=>'Team #', 'inputType'=>'textInput', 'options'=>['pluginOptions'=>['min'=>1, 'max'=>5]] ], 'hAlign'=>'right', 'vAlign'=>'middle', 'width'=>'50px' ], // 'team', // 'notes:ntext', ['class' => 'yii\grid\ActionColumn'], ], 'storage'=>DynaGrid::TYPE_SESSION, 'theme'=>'panel-danger', 'gridOptions'=>[ 'dataProvider'=>$dataProvider, 'filterModel'=>$searchModel, 'panel'=>['heading'=>'<h3 class="panel-title">Library</h3>'], ], 'options'=>['id'=>'dynagrid-1'] // a unique identifier is important ]); ?> This gives me a column that links to players/index&registrationID=29 My problem here is that I can't seem to get the GridView for Players to filter results so only players with a registrationID = 29 will show up. PlayersController: public function actionIndex() { $searchModel = new PlayersSearch(); if (isset($_GET['registrationID'])) $searchModel->attributes = $_GET['registrationID']; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } PlayersSearchModel: public function search($params) { $query = players::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); // setup sorting attributes BEFoRE $this->load($params) $dataProvider->setSort([ 'attributes' =>[ 'ID', 'registrationID', 'fullName' => [ 'asc' => [ 'first' => SORT_ASC, 'last' => SORT_ASC], 'desc' => [ 'first' => SORT_DESC, 'last' => SORT_DESC], 'label' => 'Full Name', 'default' => SORT_ASC ], 'email', 'phone', 'city', 'state', ] ]); if (isset($_GET['PlayersSearch']) && !($this->load($params) && $this->validate())) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); $query->joinWith(['registration']); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['ID' => $this->ID]); $query->andFilterWhere(['registrationID' => $this->registrationID]); $query->andFilterWhere(['first' => $this->first]); $query->andFilterWhere(['last' => $this->last]); $query->andFilterWhere(['email' => $this->email]); $query->andFilterWhere(['phone' => $this->phone]); $query->andFilterWhere(['city' => $this->city]); $query->andFilterWhere(['state' => $this->state]); $query->andWhere('first LIKE "%' . $this->fullName . '%" ' . 'OR last LIKE "%' . $this->fullName . '%"'); return $dataProvider; }
×
×
  • Create New...