But there is still a problem because the data in gridview can not be displayed (blank) for the ids.
To clarify I attach a file from my test results with firebug. there be seen that the value of the ids ids [] while in the picture above I select 3 rows.
if I checked all the data even ids are not displayed at all. Presumably there is a solution to this problem.
You need to give more information if you want help…
How do you call the getChecked? Can you post your new code?
Note that getChecked has 2 parameters (gridID and columnID)… if you use firebug… you can put a breakpoint on getChecked and see if it gets the column values…
I just tried this example and it works for me… so it’s something on your end…
First of all…
in this code you use the CGridView::selectableRows=>2… so this means that you can select more rows… and at the same time the checkbox will be checked… so this means that all rows that has a checkbox checked would be selected… but in your previous post in the picture… there are rows with checkbox checked… but not selected…
I cannot help you more than this… you need to debug a bit… use firebug…
BTW… if you are not… use the latest Yii version (1.1.8 ) … as there where some bug fixes about this…
$sql ="SELECT a.*,b.name as groupname,
concat(a.firstname,' ',a.lastname) as custname FROM `customer` as a
left join customer_group as b
on a.customer_group_id = b.customer_group_id";
$dprov = new CSqlDataProvider($sql,array(
'totalItemCount'=>$count,
'keyField'=>'a.customer_id',
i changed to be:
$dprov = new CSqlDataProvider($sql,array(
'totalItemCount'=>$count,
'keyField'=>'customer_id',
public function actionGetvalue()
{
// if(Yii::app()->request->isAjaxRequest)
// {
$model = new ProductForm('getRoutePlanning');
print 124; // work till this line.
if(isset($_POST['ids'])) // method $_POST can't get any value, code stop at here.
{
print 123;
print_r($_POST['ids']);
foreach($_POST['ids'] as $val)
{
echo $val . '<br/>';
}
}
// }
}
How to retrieve and return more than one value in same rows when user click the row?? $.fn.yiiGridView.getSelection only c pass one value to js. Can keyField store array??
example :
‘keyField’=>array(‘id’,‘name’),
$.fn.yiiGridView.getSelection(target_id)
There is less example for method $.fn.yiiGridView.getChecked(id,column_id),
You are already asking for a second problem… did you solve the first problem? post here the solution… .then we can get to another problem…
keyField - check it’s type in the documentation - it’s string - so no array
The value returned from getSelected() or getChecked() is the value of the key of that row - that value does not need to be displayed on the grid… but you can always use jQuery to get any other value that is shown in the selected row.