himiklab / yii2-jqgrid-widget Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
(Cross-post from http://www.yiiframework.com/forum/index.php/topic/61776-getting-himiklabs-gridjs-widget-for-yii2-working/ )
When trying to install yii2-jqgrid-widget through composer, by adding the following line to my composer.json - "himiklab/yii2-jqgrid-widget" : "*" - (with minimum stability "stable") and running composer update, I am greeted with a problem message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- himiklab/yii2-jqgrid-widget 1.0.8 requires bower-asset/jqgrid 4.7.0 -> no matching package found.
- himiklab/yii2-jqgrid-widget 1.0.7 requires bower-asset/jqgrid 4.7.0 -> no matching package found.
- Installation request for himiklab/yii2-jqgrid-widget * -> satisfiable by himiklab/yii2-jqgrid-widget[1.0.7, 1.0.8].
Здравствуйте, подскажите пожалуйста, как можно организовать передачу выбранного значения depdrop'а, чтобы можно было загрузить данные в jqgrid, зависящие от выбранных значений в depdrop'e?
Т.е., например, чтобы виджет jqgrid срабатывал после того, как установлены все значения в depdrop'e?
Мой вид
<?php
use himiklab\jqgrid\JqGridWidget;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\depdrop\DepDrop;
use app\models\Groups;
?>
<div class="wrap">
<div class="row">
<?php
$form = ActiveForm::begin();
$query = \app\models\FormObuch::find()->all();
$items = ArrayHelper::map($query,'idf','name_f');
?>
<div class="col-sm-3">
<?php
echo $form->field($model, 'name_f')->dropDownList($items,
[
'id'=>'cat-id',
'prompt' => 'Выбор формы...',
]);
?>
</div>
<div class="col-sm-3">
<?php
// Child # 1
$model = new Groups();
echo $form->field($model, 'name_g')->widget(DepDrop::classname(), [
//'type'=>DepDrop::TYPE_SELECT2,
'options'=>['id'=>'subcat-id'],
'pluginOptions'=>[
'depends'=>['cat-id'],
'placeholder'=>'Выбор группы...',
'url'=>Url::to(['/post/subcat'])
]
]);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
<?= JqGridWidget::widget([
'requestUrl' => Url::to('jqgrid'),
'gridSettings' => [
'colNames' => ['Фамилия', 'Имя', 'Отчество', 'Дата рождения', 'Номер зачетки'],
'colModel' => [
['name' => 'famil', 'index' => 'famil', 'editable' => true],
['name' => 'name', 'index' => 'name', 'editable' => true],
['name' => 'otchestvo', 'index' => 'otchestvo', 'editable' => true],
[
'name' => 'date_birth', 'index' => 'date_birth', 'editable' => true,
'formatter' => "date",
'formatoptions' => ['srcformat' => "ISO8601Long", 'newformat' => "m/d/Y"],
],
['name' => 'num_zuch', 'index' => 'num_zuch', 'editable' => true]
],
'rowNum' => 15,
'autowidth' => true,
'height' => 'auto',
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => ['multipleSearch' => true],
],
'enableFilterToolbar' => true,
'filterToolbarSettings' => [
'autosearch' => true,
'stringResult' => true,
'searchOnEnter' => true,
'defaultSearch' => "cn"
],
]) ?>
</div>
Мой контроллер
<?php
namespace app\controllers;
use app\models\FormObuch;
use app\models\Result;
use Yii;
use app\models\EntryForm;
use himiklab\jqgrid\actions\JqGridActiveAction;
use yii\helpers\Json;
![default](https://user-images.githubusercontent.com/25239310/33243859-9b9c3b36-d2fe-11e7-9362-c5f1dcf075d1.png)
class PostController extends CommonController
{
public $layout = 'basic';
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Result::className(),
'scope' => function (\yii\db\ActiveQuery $query) {
//вывод данных с idg=5
$query->select(['ids', 'famil', 'name', 'otchestvo', 'date_birth','num_zuch'])->where(['idg'=>5]);
},
],
];
}
public function actionGroups(){
$model = new FormObuch();
return $this->render('groups', ['model' => $model]);
}
public function actionSubcat() {
$out = [];
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$cat_id = $parents[0];
$out = FormObuch::getGroups($cat_id);
// the getSubCatList function will query the database based on the
// cat_id and return an array like below:
// [
// ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'],
// ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>']
// ]
$poc = Json::encode(['output'=>$out]);
echo Json::encode(['output'=>$out, 'selected'=>'']);
return;
}
}
echo Json::encode(['output'=>'', 'selected'=>'']);
}
}
Здравствуйте! Воспользовался вашим виджетом и у меня возник вопрос, возможно ли в нем реализовать подтаблицу со своим CRUD в таком виде?
Пытался сделать тоже самое с вашим виджетом, но что-то не идет.
View
<?= JqGridWidget::widget([
'requestUrl' => Url::to('jqgrid'),
'gridSettings' => [
'colNames' => ['Дата рождения', 'Имя', 'Фамилия', 'Номер зачетки'],
'colModel' => [
['name' => 'datebirth', 'index' => 'datebirth', 'editable' => true],
['name' => 'firstname', 'index' => 'firstname', 'editable' => true],
['name' => 'lastname', 'index' => 'lastname', 'editable' => true],
['name' => 'num', 'index' => 'num', 'editable' => true],
],
'rowNum' => 15,
'autowidth' => true,
'height' => 'auto',
'subGrid' => true,
'mtype' => 'GET',
'subGridUrl' => Url::to('jqsubgrid'),
'subGridModel' => [
[
'name' => ['Рейтинг', 'Присутствие'],
'width' => [200, 200],
'align' => ['left','left'],
]
],
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => ['multipleSearch' => true],
],
'enableFilterToolbar' => true,
'filterToolbarSettings' => [
'autosearch' => true,
'stringResult' => true,
'searchOnEnter' => true,
'defaultSearch' => "cn"
],
]) ?>
Controller
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => NewStudents::className(),
'scope' => function (\yii\db\ActiveQuery $query) {
$query->select(['datebirth', 'firstname', 'lastname', 'num']);
},
],
'jqsubgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Raiting::className(),
'scope' => function (\yii\db\ActiveQuery $query) {
$query->select(['raiting', 'presence']);
},
],
];
}
public function actionGroups(){
return $this->render('groups');
}
Hi, how to set Bootrap 3 style an isi it possible inline editing?
I find my filter toolbar won't work but if I use find records to filter. It can work property.
My solution is to adjust the code in controller like below. so that now it can work. but I wonder if any solution is better.
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Country::className(),
'scope' => function ($query) {
$query->select(['*']);
if (isset($_REQUEST['country_id'])){
$query->andFilterWhere(['like', 'country_id', $_REQUEST['country_id']]);
} elseif(isset($_REQUEST['country_code'])){
$query->andFilterWhere(['like', 'country_code', $_REQUEST['country_code']]);
} elseif(isset($_REQUEST['country_name'])){
$query->andFilterWhere(['like', 'country_name', $_REQUEST['country_name']]);
} elseif(isset($_REQUEST['dial_code'])){
$query->andFilterWhere(['like', 'dial_code', $_REQUEST['dial_code']]);
} elseif(isset($_REQUEST['support'])){
$query->andFilterWhere(['like', 'support', $_REQUEST['support']]);
}
},
],
];
}
'model' => Page::className(),
I'm newbie in yii2 ,I install extension with composer and I have himiklab folder in vendor,I tried to use this extension from example but not work! when i call jqgrid
I have error "Invalid Configuration – yii\base\InvalidConfigException
Object configuration must be an array containing a "class" element."
siteController
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Page::className(),
'columns' => ['title', 'author', 'language']
],
];
}
Здравствуйте, помогите решить следующую проблему.
Мой PostController.
namespace app\controllers;
use app\models\Result;
use Yii;
use app\models\EntryForm;
use himiklab\jqgrid\actions\JqGridActiveAction;
class PostController extends CommonController
{
public $layout = 'basic';
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => Result::className(),
'scope' => function ($query) {
$query->select(['ids', 'fio', 'num_zuch','idg']);
},
],
];
}
public function actionIndex(){
$model = new EntryForm();
if($model->load(Yii::$app->request->post()) && $model->validate()){
return $this->render('autoriz', ['model' => $model]);
}else{
return $this->render('autoriz', ['model' => $model]);
}
}
public function actionProgress(){
return $this->render('progress');
}
}
Представление progress
<?php
use himiklab\jqgrid\JqGridWidget;
use yii\helpers\Url;
?>
<?= JqGridWidget::widget([
'requestUrl' => Url::to('jqgrid'),
'gridSettings' => [
'colNames' => ['IDS', 'FIO', 'NUMBER', 'IDG'],
'colModel' => [
['name' => 'ids', 'index' => 'ids', 'editable' => true],
['name' => 'fio', 'index' => 'fio', 'editable' => true],
['name' => 'num_zuch', 'index' => 'num_zuch', 'editable' => true],
['name' => 'idg', 'index' => 'idg', 'editable' => true]
],
'rowNum' => 15,
'autowidth' => true,
'height' => 'auto',
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => ['multipleSearch' => true]
],
'enableFilterToolbar' => true,
])
Модель Result
namespace app\models;
use yii\db\ActiveRecord;
class Result extends ActiveRecord
{
public static function tableName()
{
return 'students';
}
}
В адресной строке если прописываю следующий url (http://mysite.ru/web/post/jqgrid?action=request), то на отдельной странице выводятся данные в json формате, но они не передаются в представление.
Объясните пожалуйста что я упустил?
In My Controller
namespace frontend\controllers;
use himiklab\jqgrid\actions\JqGridActiveAction;
use backend\models\MasterCodePiee;
class ResultEntryController extends \yii\web\Controller
{
public function actions()
{
return [
'jqgrid' => [
'class' => JqGridActiveAction::className(),
'model' => MasterCodePiee::className(),
'scope' => function ($query) {
/** @var \yii\db\ActiveQuery $query */
$query->select(['S_CODE', 'S_TITLE'])->limit(100);
},
],
];
}
public function actionIndex()
{
// $results = StudentResult::find()->limit(10)->all();
return $this->render('index'/*, ['results'=>$results]*/);
}
}
In My View
/* @var $this yii\web\View */
use himiklab\jqgrid\JqGridWidget;
use yii\helpers\Url;
use yii\helpers\BaseJson;
//echo BaseJson::encode($results);
?>
<?= JqGridWidget::widget([
'requestUrl' => Url::toRoute('jqgrid'),
'gridSettings' => [
'colNames' => ['S_CODE', 'S_TITLE'],
'colModel' => [
//['name' => 'MATRIC_NO', 'index' => 'MATRIC_NO', 'editable' => true],
['name' => 'S_CODE', 'index' => 'S_CODE', 'editable' => true],
['name' => 'S_TITLE', 'index' => 'S_TITLE', 'editable' => true]
],
'rowNum' => 15,
'autowidth' => true,
'height' => 'auto',
],
'pagerSettings' => [
'edit' => true,
'add' => true,
'del' => true,
'search' => ['multipleSearch' => true]
],
'enableFilterToolbar' => true,
]) ?>
But I got error 404 not found
Very appreciate if you can help.
Hey, do you plan to implement an action for SqlDataProvider?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.