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…
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);
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.
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.