Yii Framework Forum: How Can I Get All Values Of A Row In Gridview - Yii Framework Forum

Jump to content

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

How Can I Get All Values Of A Row In Gridview Rate Topic: -----

#1 User is offline   gerilla 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 22-July 13

Posted 22 July 2013 - 08:54 AM

hi,
i have a data gridview like this:

id name description date


when i selected a row i can get id value with yiiGridView.getChecked() function, but i wanna get name, description and date values too from selected row. i couldnt find any expalanations about that. thanks in advance...
0

#2 User is offline   FreeScott 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 31-December 12

Posted 22 July 2013 - 02:40 PM

Hi, as far as I know there is no native way to do this only by Yii, so here is my own solution:
(I suppose that the checkbox column is the first column in your grid)

var checkedRowId=$("#id-of-grid").yiiGridView('getChecked', 'id-of-checkbox-column');
var name=null;
var description=null;
var date=null;
$("#id-of-grid tr").each(function(){
    if(checkedRowId==$(this).children(':nth-child(1)').find('input').val()){ // or if(checkedRowId==$(this).find(".checkbox-column input").val()){
        name=$(this).children(':nth-child(2)').text(); // second column
        description=$(this).children(':nth-child(3)').text(); // third column
        date=$(this).children(':nth-child(4)').text(); // 4th column
    }
});
console.log(name);
console.log(description);
console.log(date);

0

#3 User is offline   gerilla 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 22-July 13

Posted 25 July 2013 - 04:38 AM

thanks dude. this is great.

i have a new question. i have two table; customers and products.

now i wanna work with this two tables in a page. for example i create products crud with crud generator. and in create page of products i wanna list customers with cgridview to select which product sold which user.

thanks
0

#4 User is offline   FreeScott 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 31-December 12

Posted 26 July 2013 - 03:33 AM

View Postgerilla, on 25 July 2013 - 04:38 AM, said:

thanks dude. this is great.

i have a new question. i have two table; customers and products.

now i wanna work with this two tables in a page. for example i create products crud with crud generator. and in create page of products i wanna list customers with cgridview to select which product sold which user.

thanks


Post the codes that you have written so far to make it easier for me to help you...
0

#5 User is offline   gerilla 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 22-July 13

Posted 26 July 2013 - 10:32 AM

View PostFreeScott, on 26 July 2013 - 03:33 AM, said:

Post the codes that you have written so far to make it easier for me to help you...


i figured it out finally thanks for your helps.
now my only problem is selecting a row in cgridview with javascript. i searched forum but i dont find anything about it. how can i select a row with jscript externally.

thanks very much again...
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