javascript - yii2 render after post-request -


i have view gridview checkboxcolumn , google-map (2amigos). user selects machines display in map selecting corresponding items in gridview. html-button submitts selected keys controller. following controler code (dataprovider gets updated post-request):

//some code before render    $dataprovider = new activedataprovider(['query'=>$query, 'pagination'=>false]); return $this->render('locating', [     'model' => $model,     'searchmodel' => $searchmodel,     'dataprovider1' => $dataprovider1,     'dataprovider' => $dataprovider,     ]); } 

and js-script html-button:

$('#showbutton').click(function(){     var keys = $('#w0').yiigridview('getselectedrows');     $.post("http://localhost:8080/eddb1/frontend/web/index.php?r=tracking/locating",     {'keylist': keys},     function(data){         console.log(data);     }); }); 

the problem is, post request result of php-render command gets writen html-string post-response view doesn't re-rendered. if same activeform instead of gridview (to select machines) , submit-button page gets re-rendered should (but way doesn't work me because need gridview filter , sorting). can map (or view) gets re-rendered post-request?

public function actionlocating() {     $searchmodel = new viewmachinessearch();     $dataprovider1 = $searchmodel->search(yii::$app->request->queryparams);     $dataprovider1->pagination = false;     $model = new trackingform();      if (yii::$app->request->post()){         $model->machine_select = yii::$app->request->post('keylist');         $machines = $model->machine_select;     }else{         $machines = $model->getmachines();     }      if(!in_array(yii::$app->user->identity->company_id, yii::$app->companiesbyuser->getcompaniesbyuser(21))){         $query = new query;         $query  ->select(['licenceplate', 'identifier', 'timestamp', 'lat', 'lng'])                 ->from('gps_live')                 ->where(['machine_id' => $machines])                 ->orderby(['timestamp' => sort_desc]);     }else{         $subquery = new query;         $subquery   ->select(['licenceplate', 'identifier', 'timestamp', 'lat', 'lng'])                     ->from('btc_m1_v1_1')                     ->join('inner join', 'machine', 'machine.id_machine = machine_id')                     ->where(['machine_id' => $machines])                     ->andwhere('lat <> 0')                     ->andwhere('lng <> 0')                     ->orderby(['timestamp' => sort_desc]);         $query = new query;         $query  ->from(['sub' => $subquery])                 ->groupby(['sub.licenceplate'])                 ->all();     }      $dataprovider = new activedataprovider(['query'=>$query, 'pagination'=>false]);     return $this->render('locating', [         'model' => $model,         'searchmodel' => $searchmodel,         'dataprovider1' => $dataprovider1,         'dataprovider' => $dataprovider,         ]); } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -