Yii Framework Forum: Yii widget-Gridview get sorting data - Yii Framework Forum

Jump to content

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

Yii widget-Gridview get sorting data Rate Topic: -----

#1 User is offline   Jedi19871109 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 05-October 17

Posted 06 October 2017 - 12:19 AM

Hi Yii masters,

Firstly sorry because my bad english. :)

I have a basic questions maybe, but i cant solve it ^^'

So my problem is that, i have a perfectly working gridview what i can sorting perfectly.

I just want to find a way to get a value, what I type into the textbox, which i use in the gridview to sorting my query,
because i want export the sorted query, into the csv file.

One of the View file code what i use:


<?php
$this->widget('application.extensions.NPager.NGridView', array(
'id' => 'usergorpu-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'ajaxUrl' => $this->ajaxUrl,
'cssFile' => Yii::app()->baseUrl . '/css/gridview/styles.css',
'template' => '{summary}{pagerlist}{pager}{items}{pager}',
'pagerlist' => array(
'8' => '8',
'10' => '10',
'25' => '25',
'50' => '50',
'100' => '100',
),
'textItemsPerPage' => 'row page',
'columns' => array(
//'id',
array(
'name' => 'searchgroup',
'value' => '(is_object($data->group) ? $data->group->name : "")',
),
array(
'name' => 'searchworkername',
'value' => '$data->worker->name',
),
),
),
),
));
?>

Thanks for your support ^^

(The picture what i attachment isnt from my program, i just add it, for a clarity. So i want the value what I type on the textbox - red circle.)

Attached File(s)


0

#2 User is offline   Fabrizio Caldarelli 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,058
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 06 October 2017 - 02:50 AM

If you need this value client-side, grab it using javascript.
If you need this value server-side (after user typed text and submitted), you have this value in $_GET array.
Yii2 by example: my book about Yii2
https://www.packtpub...nt/yii2-example
0

#3 User is offline   Jedi19871109 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 05-October 17

Posted 06 October 2017 - 04:49 AM

Thank you, after i read your answer i start searching the good way and i found it

So thank you again ^^
You helped me lots
If we meet someday i own you one beer :)

<button onclick="myFunction()">Try it</button>
<p id="demo"></p>

****** /* Gridview code*/

<script>
function myFunction() {
var Name_tbv = document.getElementById("Name_tb").value;
var Email_tbv= document.getElementById("Email_tbv").value;
document.getElementById("check").innerHTML = Name_tbv +"-"+ Email_tbv;
}
</script>
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