Hola, buenas tardes
Estoy empleando bootstrap, en especifico TbExtendedGridView y TbHighCharts, en el Grid tengo una columna de ver más (TbRelationalColumn) y al darle click aparezca el detalle de lo seleccionado y ademas dos graficas, todo me funciona bien, pero al ir navegando en otros renglones o registros del grid las graficas me dejan de aparecer, algunas veces lo hace bien y otras no, ¿alguien sabe que pueda ser? Agrego mi controlador y vistas
De antemano Gracias
Controlador
public function actionIndex()
{
$model=new Municipios('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Municipios']))
$model->attributes=$_GET['Municipios'];
$this->render('index',array(
'model'=>$model,
));
}
public function actionRelational()
{
$idMunicipio= Yii::app()->getRequest()->getParam('id');
$nombreMun = Municipios::model()->findByPk($idMunicipio);
$municipio=$nombreMun->NOMBREMUN;
$model=EstadisticaFin::model()->getGridDataProvider($idMunicipio);
$this->renderPartial('_relational', array(
'id' => Yii::app()->getRequest()->getParam('id'),
'gridDataProvider' => $model,
'gridColumns' => $this->getGridColumns(),
'municipio'=>$municipio
),false,true);
}
public function getGridColumns()
{
$gridColumns=array(
'periodo','indice_aprobacion','reprobacion');
return $gridColumns;
}
Vistas
Index.php
$gridColumns=array(‘id’,
'NOMBREMUN','periodo','indice_aprobacion','indice_reprobacion');
$this->widget(
'bootstrap.widgets.TbLabel',
array(
'type' => 'info',
'label' => "INDICADORES POR MUNICIPIO",
)
);
$this->widget(‘bootstrap.widgets.TbExtendedGridView’, array(
//'filter'=>$person,
'type'=>'striped bordered',
'dataProvider'=>$model->search(),
'template' => '{pager}{summary}{items}{pager}',
'pagerCssClass' => 'pagination',
'rowCssClass' => 'pagination',
'responsiveTable' => true,
'enablePagination' => false,
'columns' => array_merge(array(
array(
'class'=>'bootstrap.widgets.TbRelationalColumn',
'name' => 'Ver más',
'url' => $this->createUrl('municipal/relational'),
'value'=> '"+"',
)
),$gridColumns),
));
$pos=0;
foreach($data = $model->search()->getData() as $d1)
{
if($d1->id>0){
$datax[$pos]=$d1->NOMBREMUN;
$dataR[$pos]=(float)$d1->indice_reprobacion;
$dataA[$pos]=(float)$d1->indice_aprobacion;
$pos++;
}
}
$this->widget(
'bootstrap.widgets.TbHighCharts',
array(
'options' => array(
'title' => array(
'text' => 'Indicador Aprobación por Municipio',
'x' => -20 //center
),
'xAxis' => array(
'title' =>array('text'=>'Municipios'),
'categories' => $datax
),
'yAxis' => array(
'title' => array(
'text' => '',
),
'plotLines' => [
[
'value' => 0,
'width' => 1,
'color' => '#808080'
]
],
),
'tooltip' => array(
'valueSuffix' => ''
),
'legend' => array(
'layout' => 'vertical',
'align' => 'right',
'verticalAlign' => 'middle',
'borderWidth' => 0
),
'series' => array(
[
'name' => 'indice_aprobacion',
'data'=>$dataA
],
),
'credits' => array('enabled' => false),
),
'htmlOptions' => array(
'style' => 'width: 780px; height: 300px; margin: 0 auto'
)
)
);
$this->widget(
'bootstrap.widgets.TbHighCharts',
array(
'options' => array(
'title' => array(
'text' => 'Indicador Reprobación por Municipio',
'x' => -20 //center
),
'xAxis' => array(
'title' =>array('text'=>'Municipios'),
'categories' => $datax
),
'yAxis' => array(
'title' => array(
'text' => '',
),
'plotLines' => [
[
'value' => 0,
'width' => 1,
'color' => '#808080'
]
],
),
'tooltip' => array(
'valueSuffix' => ''
),
'legend' => array(
'layout' => 'vertical',
'align' => 'right',
'verticalAlign' => 'middle',
'borderWidth' => 0
),
'series' => array(
[
'name' => 'indice_reprobacion',
'data'=>$dataR
],
),
'credits' => array('enabled' => false),
),
'htmlOptions' => array(
'style' => 'width: 780px; height: 300px; margin: 0 auto'
)
)
);
_relational.php
Yii::app()->clientScript->registerCoreScript(’/extensions/highcharts/assets/excanvas.js’);
Yii::app()->clientScript->registerCoreScript(’/extensions/highcharts/assets/visualize.jQuery.js’);
Yii::app()->clientScript->registerCoreScript(’/extensions/highcharts/highcharts.js’);
Yii::import(‘application.components.HighchartsSnippet’, true);
echo CHtml::tag(‘h4’,array(),‘Detalle del Municipio : "’.$id.’"’);
$cadena="Detalle del Municipio $municipio";
$this->widget(
'bootstrap.widgets.TbLabel',
array(
'type' => 'info',
// 'success', 'warning', 'important', 'info' or 'inverse'
'label' => $cadena,
)
);
$pos=0;
foreach($data2 = $gridDataProvider->getData() as $d2)
{
$dataxd[$pos]=$d2->periodo;
$dataRd[$pos]=(float)$d2->reprobacion;
$dataAd[$pos]=(float)$d2->indice_aprobacion;
$pos++;
}
$this->widget(‘bootstrap.widgets.TbExtendedGridView’, array(
'type'=>'striped bordered',
'dataProvider' => $gridDataProvider,
'template' => "{items}",
'columns' => array_merge($gridColumns),
));
$this->widget(
'bootstrap.widgets.TbHighCharts',
array(
'options' => array(
'title' => array(
'text' => 'Indicador Aprobación Municipio '.$municipio,
'x' => -20 //center
),
'xAxis' => array(
'title' =>array('text'=>'Periodo'),
'categories' => $dataxd
),
'yAxis' => array(
'title' => array(
'text' => '',
),
'plotLines' => [
[
'value' => 0,
'width' => 1,
'color' => '#808080'
]
],
),
'tooltip' => array(
'valueSuffix' => ''
),
'legend' => array(
'layout' => 'vertical',
'align' => 'right',
'verticalAlign' => 'middle',
'borderWidth' => 0
),
'series' => array(
[
'name' => 'indice_aprobacion',
'data'=>$dataAd
],
),
'credits' => array('enabled' => false),
),
'htmlOptions' => array(
'style' => 'width: 780px; height: 300px; margin: 0 auto'
)
)
);
$this->widget(
'bootstrap.widgets.TbHighCharts',
array(
'options' => array(
'title' => array(
'text' => 'Indicador Reprobación Municipio '.$municipio,
'x' => -20 //center
),
'xAxis' => array(
'title' =>array('text'=>'Periodo'),
'categories' => $dataxd
),
'yAxis' => array(
'title' => array(
'text' => '',
),
'plotLines' => [
[
'value' => 0,
'width' => 1,
'color' => '##FE2E2E'
]
],
),
'tooltip' => array(
'valueSuffix' => ''
),
'legend' => array(
'layout' => 'vertical',
'align' => 'right',
'verticalAlign' => 'middle',
'borderWidth' => 0
),
'series' => array(
[
'name' => 'indice_reprobacion',
'data'=>$dataRd
],
),
'credits' => array('enabled' => false),
),
'htmlOptions' => array(
'style' => 'width: 780px; height: 300px; margin: 0 auto'
)
)
);