yii2-advanced-app

Yii2 Show/Hide kartik treeview nodes

女生的网名这么多〃 提交于 2020-07-01 06:09:27
问题 I am using Kartik Tree Manager. I am able to add, remove, update nodes. There is more requirement, that is to show/hide nodes on the basis of user access. i.e. when a user is given a specific node(s) then only that particular node(s) with all the child (if any) should be shown. What I have done so far? I have created a table user-node in which I am assigning a node id to a user as shown below What I want to do Now I want to show only the specified node with its child node only and hide other

kartik tree view show different views on each node click

非 Y 不嫁゛ 提交于 2020-06-27 11:21:54
问题 I am working on Yii2 . I have created a tree using kartik tree manager. By default on each node click it shows me ID , name etc. But I want to show other data. Below is my code <?= TreeView::widget([ 'query' => \common\models\MdcNode::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Root'], 'rootOptions' => ['label'=>'<span class="text-primary">Root</span>'], 'topRootAsHeading' => true, // this will override the headingOptions 'fontAwesome' => true, 'isAdmin' => false, //

How to hide columns based on condition in yii2 gridview?

放肆的年华 提交于 2020-06-17 14:44:21
问题 I have placed a conditional statement in my index page. Controller $type ="402"; // type can me 401 and 403 $searchModel = new MdcmetersdataSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'type' => $type ]); Index.php <?php if($type == '401') { $columns = [ ['class' => 'yii\grid\SerialColumn'], 'device_id', 'cust_id', 'msn', 'current_p1', 'current_p2', 'current_p3',

Yii2 Chart is not defined

谁都会走 提交于 2020-05-05 21:23:44
问题 I am trying to show some data on the chart while using Yii2 . I have installed Yii2 Chart JS via the composer. Below is the code is taken from the documentation use practically\chartjs\Chart; Chart::widget([ 'type' => Chart::TYPE_BAR, 'datasets' => [ [ 'data' => [ 'Label 1' => 10, 'Label 2' => 20, 'Label 3' => 30 ] ] ] ]); Now when I refreshed this page I not seeing any chart. But in inspect->console I am getting an error Uncaught ReferenceError: Chart is not defined Update 1 Here is my

Yii2 Chart is not defined

江枫思渺然 提交于 2020-05-05 21:20:54
问题 I am trying to show some data on the chart while using Yii2 . I have installed Yii2 Chart JS via the composer. Below is the code is taken from the documentation use practically\chartjs\Chart; Chart::widget([ 'type' => Chart::TYPE_BAR, 'datasets' => [ [ 'data' => [ 'Label 1' => 10, 'Label 2' => 20, 'Label 3' => 30 ] ] ] ]); Now when I refreshed this page I not seeing any chart. But in inspect->console I am getting an error Uncaught ReferenceError: Chart is not defined Update 1 Here is my

Removing NaN from date time returned in javascript

半城伤御伤魂 提交于 2020-05-04 06:56:30
问题 I am working on yii2 . In my javascript, I have a formula through which I am getting some data. The data is then passed to chart and chart renders it. var arry_kwh = []; arry_kwh = <?php echo json_encode($dataPointskWh, JSON_NUMERIC_CHECK); ?>; var arry_kwh_diff = []; var i = 0; for (; i < arry_kwh.length - 1; i++) { arry_kwh_diff[i] = { label: arry_kwh[i].label + ((arry_kwh[i + 1].label - arry_kwh[i].label) / 2), y: (arry_kwh[i + 1].y - arry_kwh[i].y) }; } console.log(JSON.stringify(arry_kwh

Array to string conversion while using canvas js in yii2

坚强是说给别人听的谎言 提交于 2020-04-30 09:17:38
问题 I am trying to load a chart on my index page in yii2 project . Below is my code <?PHP $dataPoints1 = array( array("label"=> "2010", "y"=> 36.12), array("label"=> "2011", "y"=> 34.87), array("label"=> "2012", "y"=> 40.30), array("label"=> "2013", "y"=> 35.30), array("label"=> "2014", "y"=> 39.50), array("label"=> "2015", "y"=> 50.82), array("label"=> "2016", "y"=> 74.70) ); $dataPoints2 = array( array("label"=> "2010", "y"=> 64.61), array("label"=> "2011", "y"=> 70.55), array("label"=> "2012",

Adding minutes to date time not working properly

半世苍凉 提交于 2020-04-29 03:39:23
问题 I am working on Yii2 . In it I am trying to insert data into 3 different stages. i.e. I am using 3 queries one by one to insert different types of data. The data insertion is perfect but date-time is not. As I want to add data continuously so I have added a for loop . But the date-time it's inserting is always the same. See my code below for ($i = 0; $i <= 60; $i++) { $dt = date('Y-m-d H:i:s'); $model401->data_date_time = date('Y-m-d H:i:s', strtotime('+5 minutes', strtotime($dt))); $model402

yii2 captcha not change on page refresh

喜欢而已 提交于 2020-04-13 06:13:10
问题 I am using the default captcha implementation of the yii2 advanced framework. I have a problem: I want to change my captcha code every time I refresh a page but when I refresh the page my captcha code does not change. 回答1: The most correct solution will be to create your own CaptchaAction , that extends yii\captcha\CaptchaAction and override the run() method as follows: namespace app\actions; // Change to your own class CaptchaAction extends yii\captcha\CaptchaAction { public $autoRegenerate

Yii2 Invalid Configuration, cookieValidationKey must be configured with a secret key error when accessing the API

穿精又带淫゛_ 提交于 2020-03-05 00:21:13
问题 I am encountering an error whenever I am trying to access my self written API. { "name": "Invalid Configuration", "message": "yii\web\Request::cookieValidationKey must be configured with a secret key.", "code": 0, "type": "yii\base\InvalidConfigException", "file": "F:\xampp\htdocs\inventory-web\vendor\yiisoft\yii2\web\Request.php", "line": 1669, "stack-trace": [ "#0 F:\xampp\htdocs\inventory-web\vendor\yiisoft\yii2\web\Request.php(1651): yii\web\Request->loadCookies()", "#1 F:\xampp\htdocs